pyrolab.server.LockableDaemon#
- class LockableDaemon(*args, **kwargs)[source]#
Bases:
DaemonA LockableDaemon supports lockable resources.
Lockable resources are objects that can be locked by a client. This is useful for preventing multiple clients from accessing the same resource simultaneously. The lock can be released manually, or is automatically released when the client disconnects.
Only objects with instance behavior “single” can be locked.
- Parameters:
- hoststr or None
The hostname or IP address to bind the server on. Default is None which means it uses the configured default (which is localhost). It is necessary to set this argument to a visible hostname or ip address, if you want to access the daemon from other machines.
- portint, optional
Port to bind the server on. Defaults to 0, which means to pick a random port.
- unixsocketstr, optional
The name of a Unix domain socket to use instead of a TCP/IP socket. Default is None (don’t use).
- nathoststr, optional
hostname to use in published addresses (useful when running behind a NAT firewall/router). Default is None which means to just use the normal host. For more details about NAT, see Pyro behind a NAT router/firewall.
- natportint, optional
Port to use in published addresses (useful when running behind a NAT firewall/router). If you use 0 here, Pyro will replace the NAT-port by the internal port number to facilitate one-to-one NAT port mappings.
- interfaceDaemonObject, optional
Optional alternative daemon object implementation (that provides the Pyro API of the daemon itself).
- connected_socketSocketConnection, optional
Pptional existing socket connection to use instead of creating a new server socket.
- Attributes:
Methods
Override to return a dict with custom user annotations to be sent with each response message.
clientDisconnect(conn)Automatically releases any locked resources in the event of a client disconnect.
close()Close down the server and release resources
combine(daemon)Combines the event loop of the other daemon in the current daemon's loop.
events(eventsockets)for use in an external event loop: handle any requests that are pending for this daemon
handleRequest(conn)Handle incoming Pyro request.
Override this to add custom periodic housekeeping (cleanup) logic.
ping()Returns a bool (True) to indicate that the Daemon is alive and can be communicated with.
proxyFor(objectOrId[, nat])Get a fully initialized Pyro Proxy for the given object (or object id) for this daemon.
Return the version of PyroLab running the device.
register(obj_or_class[, objectId, force, weak])Register a Pyro object under the given id.
release(uri)Provides a way to force unlock a resource via the Daemon itself.
requestLoop([loopCondition])Goes in a loop to service incoming requests, until someone breaks this or calls shutdown from another thread.
resetMetadataCache(objectOrId[, nat])Reset cache of metadata when a Daemon has available methods/attributes dynamically updated.
serveSimple(objects[, host, port, daemon, ...])Backwards compatibility method to fire up a daemon and start serving requests.
shutdown()Cleanly terminate a daemon that is running in the requestloop.
unregister(objectOrId)Remove a class or object from the known objects inside this daemon.
uriFor(objectOrId[, nat])Get a URI for the given object (or object id) from this daemon.
validateHandshake(conn, data)Override this to create a connection validator for new client connections.