Skip to content

Event Handlers 2.0 (Event.py) #232

Closed
@thiell

Description

@thiell

Worker and Task classes are becoming too complex and not flexible enough, we need to move some of the features managed there to event handlers. For example, feature #231 should be implemented using extended event handlers described in this ticket.

Indeed the original event handling mechanism is not flexible enough, so it must itself be changed. Some of the current limitations of Event.EventHandler are:

  • access to node, msg or rc are done through Worker.current_ accessors instead of directly accessible method arguments
  • the API do not support named Engine I/O streams (d3e23a6b0f8129118df09568c411a5eef1968117)
  • ...

My proposal is to define a new module named Event2.py defining a new EventHandler base class.

Changes Event2.EventHandler vs. Event.EventHandler:

  • ev_error is merged with ev_read which becomes "named stream aware"
  • ev_read and ev_hup get a full arguments list (other idea is to use **kwargs but doesn't seem to be the more convenient solution):
    • def ev_read(self, worker, node, fname, msg):
    • def ev_hup(self, worker, node, rc):

Change in Worker:

  • Worker detects the use of Event2.EventHandler and delegates further work to it, otherwise (V1) there is no change
  • when no handler is assigned to a Worker, use DefaultEventHandler which supports MsgTree management (compat) CHANGED: DefaultEventHandler is indeed Event2.EventHandler

Change in user-programming:

  • in Event2.EventHandler, parents method should be called if associated feature is wanted; this must be clearly documented
  • no change at all if user is still using Event.py

Included EventHandler V2:

  • DefaultEventHandler (concrete) as a compat EventHandler (Task's stdout/stderr MsgTree support) CHANGED: DefaultEventHandler is indeed Event2.EventHandler
  • see if some of CLI/Clush.py could be generalized or a ProgressEventHandler ?

[work in progress]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions