gwcelery.voevent module¶
Embed a Comet VOEvent broker and subscriber into a Celery worker by extending Celery with bootsteps.
- gwcelery.voevent.install(app)[source]¶
Register the VOEvent subsystem in the application boot steps.
gwcelery.voevent.bootsteps module¶
- class gwcelery.voevent.bootsteps.Broadcaster(consumer, **kwargs)[source]¶
Bases:
TwistedServiceComet-based VOEvent broadcaster.
Run a Comet-based VOEvent broadcaster (
comet.protocol.broadcaster.VOEventBroadcasterFactory). Starts after theReactorbootstep.A few configuration options are available:
voevent_broadcaster_address: The address to bind to, inhost:portformat.voevent_broadcaster_whitelist: A list of hostnames, IP addresses, orCIDR address ranges from which to accept connections.
The list of active connections is made available inspection with the
gwcelery inspect statscommand under thevoevent-broker-peerskey.- name = 'VOEvent broadcaster'¶
- class gwcelery.voevent.bootsteps.Reactor(consumer, **kwargs)[source]¶
Bases:
VOEventBootStepRun 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:
TwistedServiceVOEvent receiver.
Run a Comet-based VOEvent receiver (
comet.protocol.subscriber.VOEventSubscriberFactory). Starts after theReactorbootstep.A few configuration options are available:
voevent_receiver_address: The address to connect to, inhost:portformat.
The list of active connections is made available inspection with the
gwcelery inspect statscommand under thevoevent-receiver-peerskey.- 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
loggingmodule. Twisted has its own separate logging facility. Use Twisted’sPythonLoggingObserverto forward all Twisted log messages to the Pythonloggingmodule.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.
- gwcelery.voevent.util.get_host_port(address)[source]¶
Split a network address of the form
host:port.- Parameters:
network (str) – The network address.
- Returns:
host (str) – The hostname, or an empty string if missing.
port (int, None) – The port number, or None if missing.
- gwcelery.voevent.util.get_local_ivo(app)[source]¶
Create an IVOID to identify this application in VOEvent Transport Protocol packets.
- Returns:
A local IVOID composed of the machine’s fully qualified domain name and the Celery application name (for example, ivo://emfollow.ligo.caltech.edu/gwcelery).
- Return type:
- gwcelery.voevent.util.get_network(address)[source]¶
Find the IP network prefix for a hostname or CIDR notation.
- Parameters:
address (str) – A hostname, such as
ligo.org, or an IP address prefix in CIDR notation, such as127.0.0.0/8.- Returns:
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.
- Parameters:
xml_document (
comet.utility.xml.xml_document) – The XML document that was received. The raw file contents are available asxml_document.raw_bytes. Thelxml.etreerepresentation of the document is available asxml_document.element.