FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-osc/examples/async_server.py at main · fltodd/python-osc · GitHub
fltodd
/
python-osc
Public
forked from
attwad/python-osc
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-osc
/
examples
/
async_server.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (29 loc) · 1.03 KB
Breadcrumbs
python-osc
/
examples
/
async_server.py
Copy path
File metadata and controls
42 lines (29 loc) · 1.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import
sys
from
pythonosc
.
osc_server
import
AsyncIOOSCUDPServer
from
pythonosc
.
dispatcher
import
Dispatcher
import
asyncio
def
filter_handler
(
address
,
*
args
):
print
(
f"
{
address
}
:
{
args
}
"
)
dispatcher
=
Dispatcher
()
dispatcher
.
map
(
"/filter"
,
filter_handler
)
ip
=
"127.0.0.1"
port
=
1337
async
def
loop
():
"""Example main loop that only runs for 10 iterations before finishing"""
for
i
in
range
(
10
):
print
(
f"Loop
{
i
}
"
)
await
asyncio
.
sleep
(
1
)
async
def
init_main
():
server
=
AsyncIOOSCUDPServer
((
ip
,
port
),
dispatcher
,
asyncio
.
get_event_loop
())
transport
,
protocol
=
(
await
server
.
create_serve_endpoint
()
)
# Create datagram endpoint and start serving
await
loop
()
# Enter main loop of program
transport
.
close
()
# Clean up serve endpoint
if
sys
.
version_info
>=
(
3
,
7
):
asyncio
.
run
(
init_main
())
else
:
# TODO(python-upgrade): drop this once 3.6 is no longer supported
event_loop
=
asyncio
.
get_event_loop
()
event_loop
.
run_until_complete
(
init_main
())
event_loop
.
close
()
Back
|
FazBrowse Home
|
New Git URL