Commit 2ac9c337 authored by Jim Fulton's avatar Jim Fulton

Bug Fixed:

  ZEO manages a separate thread for client network IO.  It created
  this thread on import, which caused problems for applications that
  implemented daemon behavior by forking.  Now, the client thread
  isn't created until needed.
parent f30f64af
...@@ -2,6 +2,17 @@ ...@@ -2,6 +2,17 @@
Change History Change History
================ ================
3.9.2 (2009-10-??)
==================
Bugs Fixed
----------
- ZEO manages a separate thread for client network IO. It created
this thread on import, which caused problems for applications that
implemented daemon behavior by forking. Now, the client thread
isn't created until needed.
3.9.1 (2009-10-01) 3.9.1 (2009-10-01)
================== ==================
......
...@@ -52,6 +52,8 @@ import zope.testing.setupstack ...@@ -52,6 +52,8 @@ import zope.testing.setupstack
logger = logging.getLogger('ZEO.tests.testZEO') logger = logging.getLogger('ZEO.tests.testZEO')
ZEO.zrpc.connection.start_client_thread()
class DummyDB: class DummyDB:
def invalidate(self, *args): def invalidate(self, *args):
pass pass
......
...@@ -24,12 +24,13 @@ from ZODB.loglevels import BLATHER ...@@ -24,12 +24,13 @@ from ZODB.loglevels import BLATHER
from ZEO.zrpc.log import log from ZEO.zrpc.log import log
import ZEO.zrpc.trigger import ZEO.zrpc.trigger
from ZEO.zrpc.connection import ManagedClientConnection from ZEO.zrpc.connection import ManagedClientConnection, start_client_thread
class ConnectionManager(object): class ConnectionManager(object):
"""Keeps a connection up over time""" """Keeps a connection up over time"""
def __init__(self, addrs, client, tmin=1, tmax=180): def __init__(self, addrs, client, tmin=1, tmax=180):
start_client_thread()
self.addrlist = self._parse_addrs(addrs) self.addrlist = self._parse_addrs(addrs)
self.client = client self.client = client
self.tmin = min(tmin, tmax) self.tmin = min(tmin, tmax)
......
...@@ -52,15 +52,15 @@ def client_exit(): ...@@ -52,15 +52,15 @@ def client_exit():
atexit.register(client_exit) atexit.register(client_exit)
def client_loop(): def client_loop():
map = client_map global client_running
client_running = True
client_exit_event.clear()
map = client_map
read = asyncore.read read = asyncore.read
write = asyncore.write write = asyncore.write
_exception = asyncore._exception _exception = asyncore._exception
loop_failures = 0 loop_failures = 0
client_exit_event.clear()
global client_running
client_running = True
while client_running and map: while client_running and map:
try: try:
...@@ -153,9 +153,19 @@ def client_loop(): ...@@ -153,9 +153,19 @@ def client_loop():
client_exit_event.set() client_exit_event.set()
client_thread = threading.Thread(target=client_loop, name=__name__) client_thread_lock = threading.Lock()
client_thread.setDaemon(True) client_thread = None
client_thread.start() def start_client_thread():
client_thread_lock.acquire()
try:
global client_thread
if client_thread is None:
client_thread = threading.Thread(target=client_loop, name=__name__)
client_thread.setDaemon(True)
client_thread.start()
finally:
client_thread_lock.release()
# #
############################################################################## ##############################################################################
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment