Skip to content

Commit

Permalink
Fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kpodp0ra committed Feb 16, 2021
1 parent c87e280 commit 9a0cac3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ An asynchronous client library for [신경](https://github.com/queer/singyeong),

If 신경 is alpha quality software, then Singyeong.py is pre-alpha quality software. Expect things to break spectacularly.

## Installing
You can get the library directly from PyPI:
```shell
python3 -m pip install -U singyeong.py
```
If you are using Windows, then the following should be used instead:
```shell
py -3 -m pip install -U singyeong.py
```
### Install with faster json support

```shell
pip install singyeong.py[ujson]
```

### Install with msgpack support

```shell
pip install singyeong.py[msgpack]
```


## Event Reference
This section outlines the different types of events listened by Client.

Expand Down Expand Up @@ -236,3 +258,7 @@ stdout of your program.
For more information, check the documentation and tutorial of the
[logging](https://docs.python.org/3/library/logging.html) module.

# To-Do
- Metadata support :)
- Queues
- Unit tests
2 changes: 1 addition & 1 deletion singyeong/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__author__ = 'StartIT'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 StartIT'
__version__ = '1.0.1a'
__version__ = '1.0.1'

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

Expand Down
4 changes: 2 additions & 2 deletions singyeong/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ async def maybe_coroutine(f, *args, **kwargs):
return value


def create_task(f, *args, **kwargs) -> None:
def create_task(loop, f, *args, **kwargs) -> None:
value = f(*args, **kwargs)
if _isawaitable(value):
asyncio.create_task(value)
loop.create_task(value)


def with_type(value):
Expand Down
5 changes: 3 additions & 2 deletions singyeong/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def poll_event(self):
return

if op == OpCode.READY:
create_task(self.on_ready)
create_task(self.loop, self.on_ready)
return

if op == OpCode.HEARTBEAT_ACK:
Expand All @@ -128,13 +128,14 @@ async def poll_event(self):
except AssertionError:
pass
except Exception as ex:
create_task(self.on_error, ex)
create_task(self.loop, self.on_error, ex)

def handle_dispatch(self, data):
if data['t'] in ("SEND", "BROADCAST"):
payload = data['d']

create_task(
self.loop,
self.on_message,
Message(
nonce=payload.get('nonce'),
Expand Down

0 comments on commit 9a0cac3

Please sign in to comment.