whylogs.api.logger.experimental.logger.actor.thread_actor#

Module Contents#

Classes#

ThreadQueueWrapper

Implementation of QueueWrapper sufficient for use in the threaded actor.

ThreadActor

Subclass of Actor that uses a thread to process messages.

Attributes#

whylogs.api.logger.experimental.logger.actor.thread_actor.DefaultQueueWrapperType#
class whylogs.api.logger.experimental.logger.actor.thread_actor.ThreadQueueWrapper#

Bases: whylogs.api.logger.experimental.logger.actor.actor.QueueWrapper[DefaultQueueWrapperType], Generic[DefaultQueueWrapperType]

Implementation of QueueWrapper sufficient for use in the threaded actor.

send(message: DefaultQueueWrapperType, timeout: float = DEFAULT_TIMEOUT) None#
Parameters
  • message (DefaultQueueWrapperType) –

  • timeout (float) –

Return type

None

send_many(messages: List[DefaultQueueWrapperType], timeout: float = DEFAULT_TIMEOUT) None#
Parameters
  • messages (List[DefaultQueueWrapperType]) –

  • timeout (float) –

Return type

None

get(timeout: float = DEFAULT_TIMEOUT) Optional[DefaultQueueWrapperType]#
Parameters

timeout (float) –

Return type

Optional[DefaultQueueWrapperType]

get_many(timeout: float = DEFAULT_TIMEOUT, max: Optional[int] = None) List[DefaultQueueWrapperType]#
Parameters
  • timeout (float) –

  • max (Optional[int]) –

Return type

List[DefaultQueueWrapperType]

size() int#
Return type

int

close() None#
Return type

None

whylogs.api.logger.experimental.logger.actor.thread_actor.ThreadMessageType#
class whylogs.api.logger.experimental.logger.actor.thread_actor.ThreadActor(queue_config: whylogs.api.logger.experimental.logger.actor.actor.QueueConfig = QueueConfig())#

Bases: whylogs.api.logger.experimental.logger.actor.actor.Actor[ThreadMessageType], threading.Thread, Generic[ThreadMessageType]

Subclass of Actor that uses a thread to process messages.

Parameters

queue_config (whylogs.api.logger.experimental.logger.actor.actor.QueueConfig) –

property name#

A string used for identification purposes only.

It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.

property ident#

Thread identifier of this thread or None if it has not been started.

This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.

property daemon#

A boolean value indicating whether this thread is a daemon thread.

This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.

The entire Python program exits when only daemon threads are left.

run() None#

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

Return type

None

close_message_handled() bool#
Return type

bool

set_close_message_handled() None#
Return type

None

close_message_wait() None#
Return type

None

is_done() bool#
Return type

bool

set_done() None#

Set this actor as done, meaning it has finished processing all messages.

Return type

None

done_wait() None#
Return type

None

set_closed() None#

Sets this actor as closed, meaning it should no longer accept messages.

Return type

None

is_closed() bool#
Return type

bool

close() None#
Return type

None

abstract process_batch(batch: List[Union[MessageType, CloseMessage]], batch_type: Type[Union[MessageType, CloseMessage]]) None#
Parameters
Return type

None

send(message: Union[MessageType, CloseMessage]) None#
Parameters

message (Union[MessageType, CloseMessage]) –

Return type

None

send_many(messages: List[Union[MessageType, CloseMessage]]) None#
Parameters

messages (List[Union[MessageType, CloseMessage]]) –

Return type

None

process_messages() None#
Return type

None

start()#

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

join(timeout=None)#

Wait until the thread terminates.

This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.

When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be join()ed many times.

join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.

is_alive()#

Return whether the thread is alive.

This method returns True just before the run() method starts until just after the run() method terminates. See also the module function enumerate().

isDaemon()#
setDaemon(daemonic)#
getName()#
setName(name)#