[Zope-Checkins] CVS: Zope/lib/python/ZServer/PubCore - ZEvent.py:1.12 ZRendezvous.py:1.10 ZServerPublisher.py:1.9 __init__.py:1.8
Fred L. Drake, Jr.
fred@zope.com
Tue, 18 Mar 2003 16:15:47 -0500
Update of /cvs-repository/Zope/lib/python/ZServer/PubCore
In directory cvs.zope.org:/tmp/cvs-serv23589/ZServer/PubCore
Added Files:
ZEvent.py ZRendezvous.py ZServerPublisher.py __init__.py
Log Message:
Move ZServer into new location, including configuration support from the
new-install-branch.
=== Zope/lib/python/ZServer/PubCore/ZEvent.py 1.11 => 1.12 ===
--- /dev/null Tue Mar 18 16:15:47 2003
+++ Zope/lib/python/ZServer/PubCore/ZEvent.py Tue Mar 18 16:15:16 2003
@@ -0,0 +1,37 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+"""Simple Event Manager Based on Pipes
+"""
+
+from ZServer.medusa.thread.select_trigger import trigger
+from asyncore import socket_map
+
+class simple_trigger(trigger):
+ def handle_close(self):
+ pass
+
+the_trigger=simple_trigger()
+
+def Wakeup(thunk=None):
+ global the_trigger
+ try:
+ the_trigger.pull_trigger(thunk)
+ except OSError, why:
+ # this broken pipe as a result of perhaps a signal
+ # we want to handle this gracefully so we get rid of the old
+ # trigger and install a new one.
+ if why[0] == 32:
+ del socket_map[the_trigger._fileno]
+ the_trigger = simple_trigger() # adds itself back into socket_map
+ the_trigger.pull_trigger(thunk)
=== Zope/lib/python/ZServer/PubCore/ZRendezvous.py 1.9 => 1.10 ===
--- /dev/null Tue Mar 18 16:15:47 2003
+++ Zope/lib/python/ZServer/PubCore/ZRendezvous.py Tue Mar 18 16:15:16 2003
@@ -0,0 +1,63 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+import thread
+from ZServerPublisher import ZServerPublisher
+
+class ZRendevous:
+
+ def __init__(self, n=1):
+ sync=thread.allocate_lock()
+ self._a=sync.acquire
+ self._r=sync.release
+ pool=[]
+ self._lists=pool, [], []
+ self._a()
+ try:
+ while n > 0:
+ l=thread.allocate_lock()
+ l.acquire()
+ pool.append(l)
+ thread.start_new_thread(ZServerPublisher,
+ (self.accept,))
+ n=n-1
+ finally: self._r()
+
+ def accept(self):
+ self._a()
+ try:
+ pool, requests, ready = self._lists
+ while not requests:
+ l=pool[-1]
+ del pool[-1]
+ ready.append(l)
+ self._r()
+ l.acquire()
+ self._a()
+ pool.append(l)
+
+ r=requests[0]
+ del requests[0]
+ return r
+ finally: self._r()
+
+ def handle(self, name, request, response):
+ self._a()
+ try:
+ pool, requests, ready = self._lists
+ requests.append((name, request, response))
+ if ready:
+ l=ready[-1]
+ del ready[-1]
+ l.release()
+ finally: self._r()
=== Zope/lib/python/ZServer/PubCore/ZServerPublisher.py 1.8 => 1.9 ===
--- /dev/null Tue Mar 18 16:15:47 2003
+++ Zope/lib/python/ZServer/PubCore/ZServerPublisher.py Tue Mar 18 16:15:16 2003
@@ -0,0 +1,26 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+from ZPublisher import publish_module
+
+class ZServerPublisher:
+ def __init__(self, accept):
+ while 1:
+ try:
+ name, request, response=accept()
+ publish_module(
+ name,
+ request=request,
+ response=response)
+ finally:
+ response._finish()
+ request=response=None
=== Zope/lib/python/ZServer/PubCore/__init__.py 1.7 => 1.8 ===
--- /dev/null Tue Mar 18 16:15:47 2003
+++ Zope/lib/python/ZServer/PubCore/__init__.py Tue Mar 18 16:15:16 2003
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+import ZRendezvous
+
+_handle=None
+_n=1
+
+def handle(*args, **kw):
+ global _handle
+
+ if _handle is None: _handle=ZRendezvous.ZRendevous(_n).handle
+
+ return apply(_handle, args, kw)
+
+def setNumberOfThreads(n):
+ global _n
+ _n=n
+ global setNumberOfThreads
+ del setNumberOfThreads