Skip to content

Commit fd6be7f

Browse files
committed
Experimental async support
for now only with Curio, but trio and pure asyncio planned
1 parent 8f43024 commit fd6be7f

File tree

7 files changed

+326
-179
lines changed

7 files changed

+326
-179
lines changed

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
name: base
66
strategy:
77
matrix:
8-
python: [ '2.7', '3.5', '3.6', '3.6', '3.7']
8+
python: [ '2.7', '3.6', '3.6', '3.7', '3.8', '3.9']
99
# os: ['ubuntu-latest', 'windows-latest', 'macOs-latest']
1010
os: ['ubuntu-latest', 'windows-latest']
1111

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,29 @@ with OSCAsyncServer(port=8000) as OSC:
136136
print("unknown address {}".format(address))
137137
```
138138

139+
Server (curio)
140+
141+
```python
142+
async def osc_app(address, port):
143+
osc = OSCCurioServer(encoding='utf8')
144+
osc.listen(address=address, port=port, default=True)
145+
146+
@osc.address("/example")
147+
async def example(*values):
148+
print(f"got {values} on /example")
149+
await curio.sleep(4)
150+
print("done sleeping")
151+
152+
@osc.address("/stop")
153+
async def stop(*values):
154+
print(f"time to leave!")
155+
await osc.stop()
156+
157+
await osc.process()
158+
159+
curio.run(osc_app, '0.0.0.0', 8000)
160+
```
161+
139162
Client
140163

141164
```python

examples/curio_example.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from curio import socket
2+
3+
import curio
4+
5+
from oscpy.server import OSCCurioServer
6+
7+
8+
async def osc_app(address, port):
9+
osc = OSCCurioServer(encoding='utf8')
10+
osc.listen(address=address, port=port, default=True)
11+
12+
@osc.address("/example")
13+
async def example(*values):
14+
print(f"got {values} on /example")
15+
await curio.sleep(4)
16+
print("done sleeping")
17+
18+
@osc.address("/test")
19+
async def test(*values):
20+
print(f"got {values} on /test")
21+
await curio.sleep(4)
22+
print("done sleeping")
23+
24+
@osc.address("/stop")
25+
async def stop(*values):
26+
print(f"time to leave!")
27+
await osc.stop()
28+
29+
await osc.process()
30+
31+
curio.run(osc_app, '0.0.0.0', 8000)

examples/thread_example.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from oscpy.server import OSCThreadServer
2+
from time import sleep
3+
4+
osc = OSCThreadServer()
5+
sock = osc.listen(address='0.0.0.0', port=8000, default=True)
6+
7+
@osc.address(b'/address')
8+
def callback(*values):
9+
print("got values: {}".format(values))
10+
11+
sleep(1000)
12+
osc.stop()

0 commit comments

Comments
 (0)