Commit 22c8f772 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: zope4: ZServer removal: Remove Lifetime which provided graceful application shutdown.

Not handled by waitress:
  https://github.com/Pylons/waitress/issues/198
parent 1d9d216b
...@@ -3,7 +3,6 @@ import errno, logging, mock, os, socket, time ...@@ -3,7 +3,6 @@ import errno, logging, mock, os, socket, time
import itertools import itertools
from threading import Thread from threading import Thread
from UserDict import IterableUserDict from UserDict import IterableUserDict
import Lifetime
import transaction import transaction
from Testing import ZopeTestCase from Testing import ZopeTestCase
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
...@@ -142,14 +141,6 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -142,14 +141,6 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
""" """
_server_address = None # (host, port) of the http server if it was started, None otherwise _server_address = None # (host, port) of the http server if it was started, None otherwise
@staticmethod
def asyncore_loop():
try:
Lifetime.lifetime_loop()
except KeyboardInterrupt:
pass
Lifetime.graceful_shutdown_loop()
def startZServer(self, verbose=False): def startZServer(self, verbose=False):
"""Start HTTP ZServer in background""" """Start HTTP ZServer in background"""
if self._server_address is None: if self._server_address is None:
...@@ -290,9 +281,6 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -290,9 +281,6 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
ZopeTestCase._print(' %i' % message_count) ZopeTestCase._print(' %i' % message_count)
old_message_count = message_count old_message_count = message_count
portal_activities.process_timer(None, None) portal_activities.process_timer(None, None)
if Lifetime._shutdown_phase:
# XXX CMFActivity contains bare excepts
raise KeyboardInterrupt
message_list = getMessageList() message_list = getMessageList()
message_count = len(message_list) message_count = len(message_list)
if time.time() >= deadline or message_count and any(x.processing_node == -2 if time.time() >= deadline or message_count and any(x.processing_node == -2
...@@ -360,7 +348,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -360,7 +348,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
def processing_node(self): def processing_node(self):
"""Main loop for nodes that process activities""" """Main loop for nodes that process activities"""
try: try:
while not Lifetime._shutdown_phase: while True:
time.sleep(.3) time.sleep(.3)
transaction.begin() transaction.begin()
try: try:
...@@ -391,7 +379,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -391,7 +379,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
timerserver_thread = None timerserver_thread = None
try: try:
while not Lifetime._shutdown_phase: while True:
time.sleep(.3) time.sleep(.3)
transaction.begin() transaction.begin()
try: try:
......
...@@ -463,9 +463,6 @@ class DebugTestResult: ...@@ -463,9 +463,6 @@ class DebugTestResult:
self.result = result self.result = result
def _start_debugger(self, tb): def _start_debugger(self, tb):
import Lifetime
if Lifetime._shutdown_phase:
return
try: try:
# try ipython if available # try ipython if available
import IPython import IPython
...@@ -624,11 +621,9 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -624,11 +621,9 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
TestRunner = unittest.TextTestRunner TestRunner = unittest.TextTestRunner
import Lifetime
from Zope2.custom_zodb import Storage, save_mysql, \ from Zope2.custom_zodb import Storage, save_mysql, \
node_pid_list, neo_cluster, zeo_server_pid, wcfs_server node_pid_list, neo_cluster, zeo_server_pid, wcfs_server
def shutdown(signum, frame, signum_set=set()): def shutdown(signum, frame, signum_set=set()):
Lifetime.shutdown(0)
signum_set.add(signum) signum_set.add(signum)
if node_pid_list is None and len(signum_set) > 1: if node_pid_list is None and len(signum_set) > 1:
# in case of ^C, a child should also receive a SIGHUP from the parent, # in case of ^C, a child should also receive a SIGHUP from the parent,
......
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