chireiden / shanghai

Shanghai
GNU General Public License v3.0
4 stars 2 forks source link

Config rewrite and addition of Context class that is passed to event hooks; also logging #38

Closed FichteFoll closed 8 years ago

FichteFoll commented 8 years ago

Things left to do in a different PR:

Closes #32, closes #36. References #8.

FichteFoll commented 8 years ago

Made some progress in a test/dispatchers-in-context branch that I will take closer look at when I'm at home.

(Didn't fix tests yet.)

Edit: nvm, can't push right now for some reason; will do later.

More edit: bleh, new ssh key did it

FichteFoll commented 8 years ago

Currently has the following issue after a reconnect is attempted:

main/main [2016-11-22 20:46:11 +0100] | ERROR    | Network task <Task finished coro=<Network.run() done, defined at E:\D
evelopment\Python\shanghai\shanghai\network.py:54> exception=KeyError("Attribute 'send_ctcp' is already defined",) creat
ed at E:\Development\Python\shanghai\shanghai\__init__.py:26> errored
Traceback (most recent call last):
  File "E:\Development\Python\shanghai\shanghai\main.py", line 135, in main
    task.result()  # cause exceptions to be raised
  File "c:\python35\Lib\asyncio\futures.py", line 274, in result
    raise self._exception
  File "c:\python35\Lib\asyncio\tasks.py", line 237, in _step
    result = coro.throw(exc)
  File "E:\Development\Python\shanghai\shanghai\network.py", line 62, in run
    self.context, NetworkEvent(NetworkEventName.INIT_CONTEXT, None))
  File "c:\python35\Lib\asyncio\coroutines.py", line 124, in throw
    return self.gen.throw(exc)
  File "E:\Development\Python\shanghai\shanghai\event.py", line 109, in dispatch
    return await super().dispatch(event.name, ctx, event.value)
  File "c:\python35\Lib\asyncio\coroutines.py", line 124, in throw
    return self.gen.throw(exc)
  File "E:\Development\Python\shanghai\shanghai\event.py", line 100, in dispatch
    results = await asyncio.gather(*tasks)
  File "c:\python35\Lib\asyncio\futures.py", line 385, in __iter__
    yield self  # This tells Task to wait for completion.
  File "c:\python35\Lib\asyncio\tasks.py", line 288, in _wakeup
    value = future.result()
  File "c:\python35\Lib\asyncio\futures.py", line 274, in result
    raise self._exception
  File "c:\python35\Lib\asyncio\tasks.py", line 239, in _step
    result = coro.send(value)
  File "c:\python35\Lib\asyncio\coroutines.py", line 121, in send
    return self.gen.send(value)
  File "E:\Development\Python\shanghai\shanghai\plugins\ctcp.py", line 57, in init_context
    Context.add_cls_method('send_ctcp', send_ctcp)
  File "E:\Development\Python\shanghai\shanghai\util.py", line 70, in add_cls_method
    cls.add_cls_attribute(name, method)
  File "E:\Development\Python\shanghai\shanghai\util.py", line 51, in add_cls_attribute
    raise KeyError("Attribute '{}' is already defined".format(name))
KeyError: "Attribute 'send_ctcp' is already defined"

This is already fixed in the follow-up test/dispatchers-in-context branch.