Python threading

Chris Mellon arkanes at gmail.com
Thu Aug 30 13:17:17 EDT 2007


On 8/30/07, Robert.R.Emmel at gmail.com <Robert.R.Emmel at gmail.com> wrote:
> Hello,
>
> I am using the threading module and the Queue module in python to to
> send out shipment tracking URL requests.
>
> Is there a way to timeout a thread within a Queue?
>
> I think the way I have it now the thread will wait until something is
> returned and will basically wait forever for that something.
>
> Between the waiting for something to be returned and the timeouts on
> the database connections, the program appears to just hang like it has
> stopped working. Any suggestions?
>
> Here is a sample of code I am using (left out some of the code for
> brevity):
>

<code snipped>

The two possible implementations:

a) Use a timeout in your get() call to allow to check for thread termination
b) push a sentinel object into the Queue that means "please exit now".



More information about the Python-list mailing list