Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
61a0bcaa
Commit
61a0bcaa
authored
3 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
rc3 - fixed tests
parent
ba126031
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/resources/cp_manager.py
+12
-5
12 additions, 5 deletions
satella/coding/resources/cp_manager.py
tests/test_coding/test_resources.py
+0
-1
0 additions, 1 deletion
tests/test_coding/test_resources.py
with
13 additions
and
7 deletions
satella/__init__.py
+
1
−
1
View file @
61a0bcaa
__version__
=
'
2.19.0rc
2
'
__version__
=
'
2.19.0rc
3
'
This diff is collapsed.
Click to expand it.
satella/coding/resources/cp_manager.py
+
12
−
5
View file @
61a0bcaa
...
...
@@ -34,8 +34,8 @@ class CPManager(Monitor, Closeable, tp.Generic[T], metaclass=abc.ABCMeta):
"""
def
__init__
(
self
,
max_number
:
int
,
max_cycle_no
:
int
):
super
().
__init__
()
Closeable
.
__init__
(
self
)
Monitor
.
__init__
(
self
)
if
sys
.
implementation
.
name
!=
'
cpython
'
:
warnings
.
warn
(
f
'
This may run bad on
{
sys
.
implementation
.
name
}
'
,
RuntimeWarning
)
self
.
connections
=
queue
.
Queue
(
max_number
)
...
...
@@ -43,29 +43,36 @@ class CPManager(Monitor, Closeable, tp.Generic[T], metaclass=abc.ABCMeta):
self
.
max_number
=
max_number
self
.
max_cycle_no
=
max_cycle_no
self
.
id_to_times
=
{}
# type: tp.Dict[int, int]
self
.
terminating
=
False
def
close
(
self
)
->
bool
:
def
close
(
self
)
->
None
:
if
super
().
close
():
while
self
.
spawned_connections
:
self
.
terminating
=
True
while
self
.
spawned_connections
>
0
:
self
.
teardown_connection
(
self
.
connections
.
get
())
self
.
spawned_connections
-=
1
def
acquire_connection
(
self
)
->
T
:
"""
Either acquire a new connection, or just establish it in the background
:return: a new connection:
:raises RuntimeError: CPManager is terminating!
"""
if
self
.
terminating
:
raise
RuntimeError
(
'
CPManager is terminating
'
)
try
:
conn
=
self
.
connections
.
get
(
False
)
except
queue
.
Empty
:
while
True
:
with
silence_excs
(
queue
.
Empty
),
Monitor
.
acquire
(
self
):
if
self
.
spawned_connections
=
=
self
.
max_number
:
if
self
.
spawned_connections
>
=
self
.
max_number
:
conn
=
self
.
connections
.
get
(
False
,
5
)
break
elif
self
.
spawned_connections
<
self
.
max_number
:
conn
=
self
.
create_connection
()
self
.
connections
.
put
(
conn
)
self
.
spawned_connections
+=
1
self
.
connections
.
put
(
conn
)
break
obj_id
=
id
(
conn
)
try
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_coding/test_resources.py
+
0
−
1
View file @
61a0bcaa
...
...
@@ -37,5 +37,4 @@ class TestResources(unittest.TestCase):
while
conns
:
cp
.
release_connection
(
conns
.
pop
())
del
cp
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