Skip to content

Commit

Permalink
WIP: zope4: ZServer removal: Remove Lifetime which provided graceful …
Browse files Browse the repository at this point in the history
…application shutdown.

Not handled by waitress:
  Pylons/waitress#198
  • Loading branch information
arnaud-fontaine committed Mar 3, 2023
1 parent 0314e61 commit 4a78fc7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
16 changes: 2 additions & 14 deletions product/ERP5Type/tests/ProcessingNodeTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import itertools
from threading import Thread
from UserDict import IterableUserDict
import Lifetime
import transaction
from Testing import ZopeTestCase
from ZODB.POSException import ConflictError
Expand Down Expand Up @@ -142,14 +141,6 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
"""
_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):
"""Start HTTP ZServer in background"""
if self._server_address is None:
Expand Down Expand Up @@ -290,9 +281,6 @@ def tic(self, verbose=0, stop_condition=lambda message_list: False, delay=30*60)
ZopeTestCase._print(' %i' % message_count)
old_message_count = message_count
portal_activities.process_timer(None, None)
if Lifetime._shutdown_phase:
# XXX CMFActivity contains bare excepts
raise KeyboardInterrupt
message_list = getMessageList()
message_count = len(message_list)
if time.time() >= deadline or message_count and any(x.processing_node == -2
Expand Down Expand Up @@ -360,7 +348,7 @@ def _restoreMailHost(self):
def processing_node(self):
"""Main loop for nodes that process activities"""
try:
while not Lifetime._shutdown_phase:
while True:
time.sleep(.3)
transaction.begin()
try:
Expand Down Expand Up @@ -391,7 +379,7 @@ def timerserver(self):

timerserver_thread = None
try:
while not Lifetime._shutdown_phase:
while True:
time.sleep(.3)
transaction.begin()
try:
Expand Down
5 changes: 0 additions & 5 deletions product/ERP5Type/tests/runUnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,6 @@ def __init__(self, result):
self.result = result

def _start_debugger(self, tb):
import Lifetime
if Lifetime._shutdown_phase:
return
try:
# try ipython if available
import IPython
Expand Down Expand Up @@ -624,11 +621,9 @@ def assertFalse():

TestRunner = unittest.TextTestRunner

import Lifetime
from Zope2.custom_zodb import Storage, save_mysql, \
node_pid_list, neo_cluster, zeo_server_pid, wcfs_server
def shutdown(signum, frame, signum_set=set()):
Lifetime.shutdown(0)
signum_set.add(signum)
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,
Expand Down

0 comments on commit 4a78fc7

Please sign in to comment.