Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
098b35d6
Commit
098b35d6
authored
Feb 22, 2019
by
oroulet
Committed by
oroulet
Feb 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directly start and stop thread_loop
parent
90ef44bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
11 deletions
+30
-11
.travis.yml
.travis.yml
+1
-1
opcua/sync.py
opcua/sync.py
+20
-8
tests/test_sync.py
tests/test_sync.py
+9
-2
No files found.
.travis.yml
View file @
098b35d6
...
...
@@ -8,7 +8,7 @@ install:
-
pip install lxml
-
pip install aiofiles
-
pip install asyncio-contextmanager
-
pip install pytest
-
pip install pytest
--upgrade
-
pip install pytest-asyncio
-
pip install cryptography
# command to run tests
...
...
opcua/sync.py
View file @
098b35d6
...
...
@@ -48,14 +48,28 @@ _ref_count = 0
_tloop
=
None
def
start_thread_loop
():
print
(
"START"
)
global
_tloop
_tloop
=
ThreadLoop
()
_tloop
.
start
()
return
_tloop
def
stop_thread_loop
():
print
(
"STOP"
)
global
_tloop
_tloop
.
stop
()
_tloop
.
join
()
def
get_thread_loop
():
global
_tloop
if
_tloop
is
None
:
_tloop
=
ThreadLoop
()
_tloop
.
start
()
start_thread_loop
()
global
_ref_count
_ref_count
+=
1
print
(
"RETURNING"
,
_tloop
,
_ref_count
)
return
_tloop
...
...
@@ -66,9 +80,7 @@ def release_thread_loop():
global
_ref_count
if
_ref_count
==
0
:
_ref_count
-=
1
print
(
"STOPPING"
,
_tloop
,
_ref_count
)
_tloop
.
stop
()
_tloop
.
join
()
stop_thread_loop
()
def
_get_super
(
func
):
...
...
@@ -90,7 +102,8 @@ def syncmethod(func):
sup
=
_get_super
(
func
)
super_func
=
getattr
(
sup
,
name
)
global
_tloop
return
_tloop
.
post
(
super_func
(
self
,
*
args
,
**
kwargs
))
result
=
_tloop
.
post
(
super_func
(
self
,
*
args
,
**
kwargs
))
return
result
return
wrapper
...
...
@@ -101,7 +114,6 @@ class Client(client.Client):
@
syncmethod
def
connect
(
self
):
print
(
"NOT HEERE"
)
pass
@
syncmethod
...
...
tests/test_sync.py
View file @
098b35d6
...
...
@@ -2,7 +2,7 @@ import time
import
pytest
from
opcua.sync
import
Client
from
opcua.sync
import
Client
,
start_thread_loop
,
stop_thread_loop
@
pytest
.
fixture
...
...
@@ -11,7 +11,14 @@ def server():
@
pytest
.
fixture
def
client
():
def
tloop
():
t_loop
=
start_thread_loop
()
yield
t_loop
stop_thread_loop
()
@
pytest
.
fixture
def
client
(
tloop
):
c
=
Client
(
"opc.tcp://localhost:4840/freeopcua/server"
)
c
.
connect
()
yield
c
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment