gpt4 book ai didi

python - 处理 couchdb 通知的外部进程导致崩溃

转载 作者:太空宇宙 更新时间:2023-11-04 03:25:14 25 4
gpt4 key购买 nike

我在通过 python 脚本处理对 couchdb 数据库的更改时遇到问题。

data = 'test'
f = open('/home/username/test','w')
f.write(data + '\n')
f.close()

这是我尝试运行的脚本(用于测试目的)。它称为“list.py”,位于“/usr/local/src/couchdb”中。我在我的“/etc/couchdb”文件夹中修改我的“local.ini”添加:

[update_notification]
list = python /usr/local/src/couchdb/list.py

每次进行修改时都应调用此脚本,但它会导致 couchdb 在我启动服务器后几乎立即崩溃。这是错误的日志(我认为)。

 [Sat, 24 Oct 2015 23:05:09 GMT] [error] [<0.6468.0>] {error_report,<0.31.0>,
{<0.6468.0>,crash_report,
[[{initial_call,
{couch_os_process,init,['Argument__1']}},
{pid,<0.6468.0>},
{registered_name,[]},
{error_info,
{exit,
{exit_status,1},
[{gen_server,terminate,6,
[{file,"gen_server.erl"},{line,744}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,239}]}]}},
{ancestors,
[couch_db_update,couch_primary_services,
couch_server_sup,<0.32.0>]},
{messages,[]},
{links,[<0.5922.0>]},
{dictionary,[]},
{trap_exit,false},
{status,running},
{heap_size,987},
{stack_size,27},
{reductions,884}],
[]]}}

[Sat, 24 Oct 2015 23:05:09 GMT] [error] [<0.5922.0>] Update notification
process <0.6468.0> died: {exit_status,

[Sat, 24 Oct 2015 23:05:09 GMT] [error] [<0.6430.0>] {error_report,<0.31.0>,
{<0.6430.0>,supervisor_report,
[{supervisor,{local,couch_db_update_notifier_sup}},
{errorContext,child_terminated},
{reason,normal},
{offender,
[{pid,<0.6467.0>},
{name,"list"},
{mfargs,
{couch_db_update_notifier,start_link,
["python /usr/local/src/couchdb/list.py"]}},
{restart_type,permanent},
{shutdown,1000},
{child_type,supervisor}]}]}}

[Sat, 24 Oct 2015 23:05:09 GMT] [error] [<0.6472.0>] ** Generic server <0.6472.0> terminating
** Last message in was {#Port<0.5590>,{exit_status,1}}
** When Server state == {os_proc,"python /usr/local/src/couchdb/list.py",
#Port<0.5590>,
#Fun<couch_os_process.2.14837184>,
#Fun<couch_os_process.3.14837184>,5000}
** Reason for termination ==
** {exit_status,1}

我错过了什么?非常感谢

最佳答案

因此,似乎在 couchdb 中处理通知的外部进程需要一个无限循环,每次出现时都会读取标准输入,否则它不起作用。

import sys

line = str(sys.stdin.readline())
while line:
print(line)
line = sys.stdin.readline()

例如,此代码 (python) 读取每个通知并打印它...

关于python - 处理 couchdb 通知的外部进程导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33324729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com