[Stackless-checkins] r52450 - stackless/sandbox/examples/stacklesssocket.py
richard.tew
python-checkins at python.org
Thu Oct 26 22:02:32 CEST 2006
Author: richard.tew
Date: Thu Oct 26 22:02:31 2006
New Revision: 52450
Modified:
stackless/sandbox/examples/stacklesssocket.py
Log:
Fix two problems.
Where we used to give a dispatcher back, now we give a socket facade. So setting "wrap_accept_socket" then set it on the facade rather than the dispatcher, resulting in it not getting used. Now setting this attribute on the facade forwards it on to the dispatcher.
Added a timeout to the asyncore polling, so that the socket module would not consume all the cpu.
Modified: stackless/sandbox/examples/stacklesssocket.py
==============================================================================
--- stackless/sandbox/examples/stacklesssocket.py (original)
+++ stackless/sandbox/examples/stacklesssocket.py Thu Oct 26 22:02:31 2006
@@ -53,7 +53,7 @@
while len(asyncore.socket_map):
# Check the sockets for activity.
- asyncore.poll(0.0)
+ asyncore.poll(0.05)
# Yield to give other tasklets a chance to be scheduled.
stackless.schedule()
@@ -88,6 +88,14 @@
# I don't like forwarding __repr__
return getattr(self.dispatcher, name)
+ def __setattr__(self, name, value):
+ if name == "wrap_accept_socket":
+ # We need to pass setting of this to the dispatcher.
+ self.dispatcher.wrap_accept_socket = value
+ else:
+ # Anything else gets set locally.
+ object.__setattr__(self, name, value)
+
def __del__(self):
# Close dispatcher if it isn't already closed
if self.dispatcher._fileno is not None:
_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins
More information about the Stackless-checkins
mailing list