Apache的prefork模式导致飞信模块多次初始化

RT

自己写的一个模块,封装了一下PyFetion,目的是尽量保持飞信可用,再就是方便点。

在模块初始化的时候创建线程,登录,然后不停的查询数据库看是否有信息要发送。

后来发现很不稳定,看了下log


[Sun Sep 26 19:59:36 2010] [warn] child process 12374 still did not exit, sending a SIGTERM
Error in my_thread_global_end(): 1 threads didn't exit
[Sun Sep 26 19:59:38 2010] [notice] caught SIGTERM, shutting down
[Sun Sep 26 20:02:24 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.5 with Suhosin-Patch mod_ssl/2.2.14 OpenSSL/0.9.8k mod_wsgi/2.8 Python/2.6.5 configured -- resuming normal operations
[Sun Sep 26 20:02:46 2010] [error] <SupervisorThread(SupervisorThread, started 140184746718992)> ('construct...',)
[Sun Sep 26 20:02:49 2010] [error] <SupervisorThread(SupervisorThread, started 140184746718992)> ('login...',)
[Sun Sep 26 20:02:54 2010] [error] <MessageThread(MessageThread, started 140184645531408)> ('message round',)
......
[Sun Sep 26 20:02:59 2010] [error] <SendSMSThread(SendSMSThread, started 140184637138704)> ('nomsg',)
[Sun Sep 26 20:03:04 2010] [error] <SendSMSThread(SendSMSThread, started 140184637138704)> ('nomsg',)
.......
[Sun Sep 26 20:03:24 2010] [error] <SupervisorThread(SupervisorThread, started 140184746718992)> ('construct...',)
[Sun Sep 26 20:03:24 2010] [error] <HeartbeatThread(HeartbeatThread, started 140184721078032)> ('beat~',)
[Sun Sep 26 20:03:24 2010] [error] <SendSMSThread(SendSMSThread, started 140184637138704)> ('nomsg',)
[Sun Sep 26 20:03:24 2010] [error] <HeartbeatThread(HeartbeatThread, started 140184721078032)> ('beat done',)

 

怎么又开始初始化了呢?

 

后来发现是因为apache的prefork模式。在fork之前每个单独的进程都认为那个module没有初始化,于是就初始化了,导致n个进程同时登录。

 

现在在想,到底是把飞信做成webservice,还是干脆改用worker模式。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值