Domain¶
- class lsst.ts.salobj.Domain¶
Bases:
object
Information common to all SalInfo instances.
The name comes from DDS; the class originally contained a DDS domain participant and associated quality of service information.
- Attributes:
- origin
int
Process ID. Used to set the
private_origin
field of output samples.- default_identity
str
Default value used for the identity field of
SalInfo
. Initalized touser_host
butController
‘s constructor sets it toSalInfo.user_index
so that allRemote
s constructed with the controller’s domain will have the controller’s identity. For testing purposes, it is allowed to change this field before constructing aRemote
.- user_host
str
username@host. This will match
identity
unless the latter is set to a CSC name.
- origin
Notes
Reads the following Environment Variables; follow the link for details:
Cleanup
It is important to close a
Domain
when you are done with it, especially in unit tests, because otherwise unreleased resources may cause problems. To make this easierDomain
is a context manager.Domain
contains a registry ofSalInfo
instances, so that it can close them when the domain is closed. The registry uses weak references to avoid circular dependencies (since SalInfo stores the domain).SalInfo
instances automatically register themselves with the provided domain.To conserve resources you should have only one
Domain
per process. Thus:Controller
creates its own Domain as attributedomain
and closes it when the controller is closed. To create aRemote
for a controller, use the domain from the controller, e.g.:controller = Controller(name="Test", index=47) try: remote = Remote(domain=controller.domain, name="Test", index=47) ... finally: await controller.close() # or if you only want the objects for the duration of a function, # e.g in a unit test: async with Controller(name="Test", index=47) as controller: remote = Remote(domain=controller.domain, name="Test", index=47) ...
If you are creating
Remote
s without aController
then you must create the Domain yourself and close it when you are finished, e.g.:domain = salobj.Domain() try: remote = salobj.Remote(domain=domain, name="Test", index=47) ... finally: await domain.close() # or if you only want the objects for the duration of a function, # e.g in a unit test: async with salobj.Domain() as domain: test_remote = salobj.Remote(domain=domain, name="Test", index=5)
Attributes Summary
Methods Summary
add_salinfo
(salinfo)Add the specified salinfo to the internal registry.
A synchronous and less thorough version of
close
.close
()Close all registered
SalInfo
.remove_salinfo
(salinfo)Remove the specified salinfo from the internal registry.
Attributes Documentation
- salinfo_set¶
Methods Documentation
- add_salinfo(salinfo: SalInfo) None ¶
Add the specified salinfo to the internal registry.
- Parameters:
- salinfo
SalInfo
SAL component information
- salinfo
- Raises:
- RuntimeError
If the salinfo is already present
- basic_close() None ¶
A synchronous and less thorough version of
close
.Intended for exit handlers and constructor error handlers.