gwcelery.voevent module

Embed a Comet VOEvent broker and subscriber into a Celery worker by extending Celery with bootsteps.


Register the VOEvent subsystem in the application boot steps.

gwcelery.voevent.bootsteps module

class gwcelery.voevent.bootsteps.Broadcaster(consumer, **kwargs)[source]

Bases: TwistedService

Comet-based VOEvent broadcaster.

Run a Comet-based VOEvent broadcaster (comet.protocol.broadcaster.VOEventBroadcasterFactory). Starts after the Reactor bootstep.

A few configuration options are available:

  • voevent_broadcaster_address: The address to bind to, in host:port format.

  • voevent_broadcaster_whitelist: A list of hostnames, IP addresses, or

    CIDR address ranges from which to accept connections.

The list of active connections is made available inspection with the gwcelery inspect stats command under the voevent-broker-peers key.

name = 'VOEvent broadcaster'
class gwcelery.voevent.bootsteps.Reactor(consumer, **kwargs)[source]

Bases: VOEventBootStep

Run the global Twisted reactor in background thread.

The Twisted reactor is a global run loop that drives all Twisted services and operations. This boot step starts the Twisted reactor in a background thread when the Celery consumer starts, and stops the thread when the Consumer terminates.

name = 'Twisted reactor'
class gwcelery.voevent.bootsteps.Receiver(consumer, **kwargs)[source]

Bases: TwistedService

VOEvent receiver.

Run a Comet-based VOEvent receiver (comet.protocol.subscriber.VOEventSubscriberFactory). Starts after the Reactor bootstep.

A few configuration options are available:

  • voevent_receiver_address: The address to connect to, in host:port format.

The list of active connections is made available inspection with the gwcelery inspect stats command under the voevent-receiver-peers key.

name = 'VOEvent receiver'
requires = ('celery.worker.consumer:Connection', step:Twisted reactor{('celery.worker.consumer:Connection',)}, 'celery.worker.consumer.tasks:Tasks')

gwcelery.voevent.logging module

Integration between the Celery, Twisted, and Comet logging systems.

gwcelery.voevent.logging.after_setup_logger(logger, loglevel, **kwargs)[source]

Celery signal handler to set up capturing of all log messages from Comet and Twisted.

  • Celery uses the Python standard library’s logging module. Twisted has its own separate logging facility. Use Twisted’s PythonLoggingObserver to forward all Twisted log messages to the Python logging module.

  • Comet uses the Twisted logging facility, but has its own separate management of log severity level (e.g., info, debug). Set Comet’s log level to match Celery’s.

gwcelery.voevent.util module

VOEvent-related utilities.


Split a network address of the form host:port.


network (str) – The network address.


  • host (str) – The hostname, or an empty string if missing.

  • port (int, None) – The port number, or None if missing.


Create an IVOID to identify this application in VOEvent Transport Protocol packets.


A local IVOID composed of the machine’s fully qualified domain name and the Celery application name (for example, ivo://

Return type:



Find the IP network prefix for a hostname or CIDR notation.


address (str) – A hostname, such as, or an IP address prefix in CIDR notation, such as


An object representing the IP address prefix.

Return type:


gwcelery.voevent.signals module

Definitions of custom Celery signals related to VOEvents.

These signals allow us to keep the VOEvent broker code decoupled from any GCN-specific logic. Notably, it allows us to keep all of the details of the GCN-specific “Notice Type” concept out of gwcelery.voevent.

gwcelery.voevent.signals.voevent_received = <Signal: voevent_received providing_args={'xml_document'}>

Fired whenever a VOEvent is received.


xml_document (comet.utility.xml.xml_document) – The XML document that was received. The raw file contents are available as xml_document.raw_bytes. The lxml.etree representation of the document is available as xml_document.element.