[Zope-dev] Xron on linux: Dispatcher thread stops after a while

Steve Alexander steve@cat-box.net
Wed, 11 Oct 2000 09:11:57 +0100


Zope 2.2.2, Xron-0-0-9, Python 1.5.2

I'm running this on i386 Linux.


I run a development server, with that server running in debus mode (-D).
I also run a production server, which runs detached from any console.

When I use Xron for a while on my development server, I get the text

   currentThread(): no current thread for 2051

or something similar printed out to the console.

This is caused by a harmless looking debugging line in
/usr/lib/python1.5/threading.py

Line 523 onwards:
  
def currentThread():
    try:
        return _active[_get_ident()]
    except KeyError:
        print "currentThread(): no current thread for", _get_ident()
        return _DummyThread()

My development server just emailed me an error (from
standard_error_message):

  Traceback (innermost last):
  File lib/python/ZPublisher/Publish.py, line
171, in publish
  File lib/python/ZPublisher/mapply.py,
line 160, in mapply
    (Object: trigger)
  File lib/python/ZPublisher/Publish.py, line
112, in call_object
    (Object: trigger)
  File lib/python/Products/Xron/XronDTMLMethod.py,
line 126, in trigger
    (Object: purge_pending_bookings)
  File lib/python/Products/Xron/XronDTMLMethod.py,
line 153, in arm
    (Object: purge_pending_bookings)
  File lib/python/Products/ZCatalog/CatalogAwareness.py,
line 193, in reindex_object
    (Object: purge_pending_bookings)
  File lib/python/Products/ZCatalog/CatalogAwareness.py,
line 189, in unindex_object
    (Object: purge_pending_bookings)
  File lib/python/Products/Xron/Schedule.py,
line 99, in uncatalog_object
    (Object: Traversable)
  File /var/tmp/python/python-root/usr/lib/python1.5/threading.py, line
287, in
set
  File /var/tmp/python/python-root/usr/lib/python1.5/threading.py, line
233, in
notifyAll
  File /var/tmp/python/python-root/usr/lib/python1.5/threading.py, line
215, in
notify
  File /var/tmp/python/python-root/usr/lib/python1.5/threading.py, line
527, in
currentThread
IOError: (0, 'Error')

Most of the top of the traceback isn't important.

What I think is happening is that the print statement on line 527 of
threading.py fails, because it is running detached from a console.

This produces an IOError, and causes the Xron Dispatcher thread to
terminate, and thus stops Xron from working until Zope is restarted.


Suggested solutions:

The obvious solution is to patch threading.py. This is not good for
folks who want to use Xron on a hosting provider's server, where they
may not be able to patch the python source.

Zope could be made to ensure it provides a /dev/null sort of file for
sys.stdout, if it is detached from the console.

A workaround would be to use the STUPID_LOG_FILE (or whatever it is
called now), as, if I remember correctly, it sends sys.stdout to a file.

Xron could do something to ensure that sys.stdout goes somewhere before
it calls Event.set().

Xron cannot just put a try: except: block around ScheduleChange.set(),
because the call to set the Event would still not succeed.


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net