[Twisted-Python] threading on windows?

Sean Riley sean at twistedmatrix.com
Tue Aug 21 18:08:34 EDT 2001

threaded initialization stuff twisted.internet.main.py is not working for me
on windows.

I propose we put all threaded initialization into a method of
twisted.internet.main and have it called from threadable.init() in one

This would include:

how about internet.main.enableThreading() which would do the work that is
currently in installWaker and set up the delayed scheduler?

On my machine with that change and some minor changes to threading.init() I
can run both threaded and non-threaded code on windows.

-----Original Message-----
From: twisted-python-admin at twistedmatrix.com
[mailto:twisted-python-admin at twistedmatrix.com]On Behalf Of Sean Riley
Sent: Tuesday, August 21, 2001 3:23 PM
To: twisted-python at twistedmatrix.com
Subject: [Twisted-Python] threading on windows?

I am trying to get a threaded twisted server to run on windows (Windows2000
SP3) and having some issues.

There is an assert in threadable.py in init():

def init(with_threads):
    global threaded, _to_be_synched, dispatcher, dispatch, Waiter,
    print "Threadable init", with_threads
    if threaded == with_threads:
    assert threaded is None
    threaded = with_threads

that always asserts whether I pass "-t" to twistd or not.  It seems that
requireInit() gets called before init() so the code:

def requireInit():
    global threaded
    if threaded is None:

is always run to initialize the global "threaded" to zero.

If i take out that "assert threaded in None" it seems to initialize
correctly on the "second" time through.

But, in internet.main the global "waker" is never initialized as
installWaker() is never called. I think that is because threadable.threaded
was initialized as 0 the "first" time through when it was called by
requireInit() and the code:

if threadable.threaded:

in internet.main.py skips the installWaker() call.

Anyone else tried running a threaded server on windows?

Twisted-Python mailing list
Twisted-Python at twistedmatrix.com

More information about the Twisted-Python mailing list