Skip to content

Give sentinel objects (or at least NEED_DATA and PAUSED) unique types #8

Closed
@njsmith

Description

@njsmith

@dabeaz has requested this, to make it easier to take the thing that comes out of next_event() and dispatch it using functools.singledispatch or something like:

 class Handler(object):
     def handle_events(self):
            while True:
                   evt = conn.next_event()
                   name = 'handle_' + type(evt).__name__
                   getattr(self, name)(evt)

     def handle_Data(self, evt):
           ...

     def handle_EndOfMessage(self, evt):
          ...

     def handle_Response(self, evt):
          ...

     def handle_NEED_DATA(self, evt):
          ...

Seems reasonable enough to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions