Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Python
Commits
ffb76bf0
Commit
ffb76bf0
authored
6 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup
parent
8381cc87
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/lib/examples/async_dumper.py
+21
-20
21 additions, 20 deletions
libs/lib/examples/async_dumper.py
with
21 additions
and
20 deletions
libs/lib/examples/async_dumper.py
+
21
−
20
View file @
ffb76bf0
...
...
@@ -5,8 +5,9 @@ import struct
from
xaal.lib
import
MessageFactory
,
config
,
helpers
ADDR
=
'
224.0.29.200
'
PORT
=
1236
ADDR
=
config
.
address
PORT
=
config
.
port
class
EchoServerProtocol
(
asyncio
.
Protocol
):
def
__init__
(
self
,
on_con_lost
):
...
...
@@ -36,25 +37,25 @@ class EchoServerProtocol(asyncio.Protocol):
def
datagram_received
(
self
,
data
,
addr
):
# print('Received %r from %s' % (data, addr))
msg
=
self
.
mf
.
decode_msg
(
data
)
if
msg
:
msg
.
dump
()
def
connection_lost
(
self
,
exc
):
print
(
f
"
Connexion lost
{
exc
}
"
)
async
def
main
():
loop
=
asyncio
.
get_running_loop
()
print
(
"
Starting UDP server
"
)
on_con_lost
=
loop
.
create_future
()
transport
,
protocol
=
await
loop
.
create_datagram_endpoint
(
lambda
:
EchoServerProtocol
(
on_con_lost
),
local_addr
=
(
ADDR
,
PORT
),
reuse_port
=
True
)
transport
,
protocol
=
await
loop
.
create_datagram_endpoint
(
lambda
:
EchoServerProtocol
(
on_con_lost
),
local_addr
=
(
ADDR
,
PORT
),
reuse_port
=
True
)
try
:
await
asyncio
.
sleep
(
3600
)
# Serve for 1 hour.
finally
:
transport
.
close
()
try
:
asyncio
.
run
(
main
())
except
KeyboardInterrupt
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment