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.
Reactor
(consumer, **kwargs)[source]¶ Bases:
gwcelery.voevent.bootsteps.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.
Broadcaster
(consumer, **kwargs)[source]¶ Bases:
gwcelery.voevent.bootsteps.TwistedService
Comet-based VOEvent broadcaster.
Run a Comet-based VOEvent broadcaster (
comet.protocol.broadcaster.VOEventBroadcasterFactory
). Starts after theReactor
bootstep.A few configuration options are available:
voevent_broadcaster_address
: The address to bind to, inhost: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 thevoevent-broker-peers
key.-
name
= 'VOEvent broadcaster'¶
-
class
gwcelery.voevent.bootsteps.
Receiver
(consumer, **kwargs)[source]¶ Bases:
gwcelery.voevent.bootsteps.TwistedService
VOEvent receiver.
Run a Comet-based VOEvent receiver (
comet.protocol.subscriber.VOEventSubscriberFactory
). Starts after theReactor
bootstep.A few configuration options are available:
voevent_receiver_address
: The address to connect to, inhost:port
format.
The list of active connections is made available inspection with the
gwcelery inspect stats
command under thevoevent-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’sPythonLoggingObserver
to forward all Twisted log messages to the Pythonlogging
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.
- Celery uses the Python standard library’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: str
-
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: ipaddress.IPv4Network
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.etree
representation of the document is available asxml_document.element
.