Ticket #3293 defect closed invalid

Opened 6 years ago

Last modified 6 years ago

selectreactor blocks callLater calls for extended periods on Posix.

Reported by: LawrenceK Owned by: LawrenceK
Priority: normal Milestone:
Component: core Keywords:
Cc: itamarst, exarkun Branch:
Author: Launchpad Bug:

Description

The main loop for selectreactor, processes any delayed calls (callLater etc.) that are ready to go and then ends up in doSelect with a timeout based on the next delayed call to run. If you then queue another callLater with a short or 0 delay it then gets blocked until the select returns.

The examples I have is using coherence where the next delayedCall is to issue MSEARCH, in the mean time an attempt to issue a command to UPNP device using soap, i.e. http over tcp blocks waiting for the MSEARCH time to expire before it gets seen.

The windows select reactor does not show the symptom so hard as it limits the select timeout to 0.5 seconds.

Attachments

twisted_bug.py Download (2.0 KB) - added by LawrenceK 6 years ago.
Shows issue I was trying to decsribe, more notes to be added

Change History

1

Changed 6 years ago by itamarst

  • cc itamarst added

I'm not sure I understand how this could happen... if you are blocking in select(), you're blocked, so you can't call callLater. If you're not blocked then the select() timeout hasn't yet been selected.

Can we see a minimal example? E.g. are you using a thread to call callLater? That'd be a bug (see Threading howto, you need to use callFromThread when calling Twisted APIs from other threads).

2

Changed 6 years ago by exarkun

  • owner changed from glyph to LawrenceK
  • cc exarkun added

Changed 6 years ago by LawrenceK

Shows issue I was trying to decsribe, more notes to be added

3

Changed 6 years ago by LawrenceK

What follows is part of the output from the test program attached. Note that there is a 30 second delay from the first connectTcp call until connectionMade. NOTE this does not occur on windows but this run was on Linux(Centos).

My scenario is that I am working with Turbogears/CherryPy and coherence (UPNP). Such that a user makes a request from the web UI that then results in a coherence call which is Soap/Http. The first stage in this request is to initiate a Tcp connection.


Wed Jun 18 13:47:26 2008 connectTCP Wed Jun 18 13:47:32 2008 connectTCP Wed Jun 18 13:47:37 2008 connectTCP Wed Jun 18 13:47:42 2008 connectTCP Wed Jun 18 13:47:48 2008 connectTCP Wed Jun 18 13:47:52 2008 connectionMade Wed Jun 18 13:47:52 2008 connectionMade Wed Jun 18 13:47:52 2008 connectionMade Wed Jun 18 13:47:52 2008 connectionMade Wed Jun 18 13:47:52 2008 connectionMade Wed Jun 18 13:47:52 2008 echo Hello, world! What a fine day it is. Bye-bye!

Wed Jun 18 13:47:52 2008 echo Hello, world! What a fine day it is. Bye-bye!

4

Changed 6 years ago by exarkun

  • status changed from new to closed
  • resolution set to invalid

The example shows the problem. You're starting the reactor in the main thread and then calling reactor.connectTCP in another thread. This isn't allow - all reactor calls must be made in the same thread (except for reactor.callFromThread which you can use in any thread to send a message to the reactor thread).

So you may want to try something like reactor.callFromThread(reactor.connectTCP, "localhost", 8000, echo_client_factory).

Note: See TracTickets for help on using tickets.