Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Andreas Grupp
python-bigbluebutton2
Commits
c55303d6
Verified
Commit
c55303d6
authored
May 17, 2020
by
Dominik George
🍻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement concurrency for group routines
parent
cacd4837
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
+25
-7
bigbluebutton/api/bigbluebutton.py
bigbluebutton/api/bigbluebutton.py
+25
-7
No files found.
bigbluebutton/api/bigbluebutton.py
View file @
c55303d6
import
concurrent.futures
from
dataclasses
import
dataclass
,
field
from
hashlib
import
sha1
from
socket
import
getfqdn
from
typing
import
Dict
,
Optional
,
Sequence
from
typing
import
Any
,
Callable
,
Dict
,
Optional
,
Sequence
from
urllib.parse
import
urlencode
from
urllib.request
import
urlopen
from
uuid
import
uuid1
...
...
@@ -97,19 +98,36 @@ class BigBlueButtonGroup:
name
:
str
apis
:
dict
=
field
(
default_factory
=
dict
)
workers
:
int
=
10
def
new
(
self
,
name
:
str
,
*
args
,
**
kwargs
)
->
BigBlueButton
:
bbb
=
BigBlueButton
(
self
,
name
,
*
args
,
**
kwargs
)
return
bbb
def
get_meetings
(
self
)
->
Dict
[
str
,
"Meeting"
]:
def
_foreach
(
self
,
method
:
str
,
*
args
,
**
kwargs
)
->
Dict
[
str
,
Any
]:
res
=
{}
for
name
,
bbb
in
self
.
apis
.
items
():
res
.
update
(
bbb
.
get_meetings
())
with
concurrent
.
futures
.
ThreadPoolExecutor
(
max_workers
=
self
.
workers
)
as
pool
:
futures
=
{}
for
name
,
bbb
in
self
.
apis
.
items
():
fn
=
getattr
(
bbb
,
method
)
futures
[
pool
.
submit
(
fn
,
*
args
,
**
kwargs
)]
=
name
for
future
in
concurrent
.
futures
.
as_completed
(
futures
):
name
=
futures
[
future
]
res
[
name
]
=
future
.
result
()
return
res
def
get_meetings
(
self
)
->
Dict
[
str
,
"Meeting"
]:
res
=
self
.
_foreach
(
"get_meetings"
)
meetings
=
{}
for
name
in
res
:
meetings
.
update
(
res
[
name
])
return
meetings
def
ssh_command
(
self
,
command
:
Sequence
[
str
],
input
:
Optional
[
str
]
=
None
)
->
Dict
[
str
,
subprocess
.
CompletedProcess
]:
res
=
{}
for
name
,
bbb
in
self
.
apis
.
items
():
res
[
name
]
=
bbb
.
ssh_command
(
command
,
input
)
res
=
self
.
_foreach
(
"ssh_command"
,
command
,
input
)
return
res
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