Micro-Threads: uthreadsleep.py -- scheduling of uthreads to c ontinue processing after given seconds

Mike Fletcher mfletch at tpresence.com
Wed May 24 09:10:04 EDT 2000


My comment regarding select.select was a (poorly worded) attempt to describe
the general pattern of a data stream which automatically triggers a callback
when it is readable/writable/whateverable. I was thinking of winsock's
WSAAsyncSelect mechanism when I looked at select.select. The general pattern
is a system-level service which should be able to perform a callback by
adding a new micro-thread to the list.

It is generally possible to implement these mechanisms as polling loops,
but, for instance, winsock's WSAAsyncSelect function could be used to create
a fairly efficient server mechanism such that the micro-thread only needs to
be active when there is actually data waiting to be read/written or
connections to be handled (see
http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/winsock/wsap
iref_6jn6.htm for the description of this select mechanism).  From what I
can see, the WSAAsyncSelect mechanism is creating a new operating system
thread in which to run the callback.  To work that properly, you would
likely want to immediately append the callback to the task list with the
given message then exit the operating system thread, allowing the next
iteration of the micro-threads loop to pick up the reactivated callback.

Although these activities can be simulated with select/poll loops, providing
the lower-level hook would seem to be more general and would allow for
creating any number of asynchronous services without the need for polling
loops (with heuristic delays) for each service.

Will continue playing now, thanks for the toys :) .
Mike

-----Original Message-----
From: Just van Rossum [mailto:just at letterror.com]
Sent: Wednesday, May 24, 2000 3:29 AM
To: Mike Fletcher; 'tismer Kaun'
Cc: Python Listserv (E-mail)
Subject: RE: Micro-Threads: uthreadsleep.py -- scheduling of uthreads to
c ontinue processing after given seconds


At 12:28 AM -0400 24-05-2000, Mike Fletcher wrote:
>My guess would be there will number of sub-classes of this general pattern.
>These are currently represented by:
>	time.sleep() -- important
>	select.select() -- extremely important for network applications

It appears to me that select.select() is only relevant in non-threaded 
programs (do you have an example of its use in a threaded 
environment?).
...




More information about the Python-list mailing list