[Twisted-Python] Twisted hangs when using pyapns

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Oct 14 16:38:06 MDT 2014


On Oct 14, 2014, at 1:06 AM, Ni Wesley <nispray at gmail.com> wrote:

> Hi all,
>    I don't know if here is the right place. 
> I hit a problem with pyapns which is based on twisted.
> 
> So, I get code from our parter and setup up env involving interacting with APNS for IOS pushing work.
> 
> I hit the problem that twisted hangs after a while's idle, I mean, when I start twisted with command: 
> twistd -r epoll web --class=pyapns.server.APNSServer --port=7077
> 
> Then, raise an notification to IOS device by pyapns(https://github.com/samuraisam/pyapns),it's OK.
> 
> However, if I let the system alone for a while, then, new raised notifications are all failed, what's more, if now I kill twisted process, and restart with the above command again, push operations are successful again.
> 
> I use python2.7 and twisted 14.0.0 on Redhat6.4.
> 
> So, anyone has hit this problem?

pyapns uses threads very heavily, and so my guess would be most likely that you're calling a Twisted API from a non-main thread.  Without seeing the code it's impossible to say.

There's some Twisted-based apache2-licensed APNS integration code available here: <https://trac.calendarserver.org/browser/CalendarServer/trunk/calendarserver/push/applepush.py>.  Unfortunately it is a little bound up with internal implementation details of calendar server, but it's almost generic and it might be worth the effort to extract, since it will almost certainly give you more robust behavior than integrating pyapns and Twisted.

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20141014/9c0e3595/attachment-0002.html>


More information about the Twisted-Python mailing list