Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Refactoring] Default port manager functions now use PortManager__Generic and LocalOperations#251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
[BUG FIX] PortManager__ThisHost::__new__ had MT-problem
After MT-lock we must to check __class__.sm_single_instance again.Refactoring - PortManager__ThisHost::__new__ is replaced with an explicit PortManager__ThisHost::get_single_instance() - PortManager__ThisHost::__init__ is deleted
  • Loading branch information
@dmitry-lipetsk
dmitry-lipetsk committedMay 5, 2025
commitf87d559790de6ecc47b4941b573ba6a1e6935c10
18 changes: 10 additions & 8 deletionstestgres/impl/port_manager__this_host.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,17 +9,19 @@ class PortManager__ThisHost(PortManager):
sm_single_instance: PortManager = None
sm_single_instance_guard = threading.Lock()

def __init__(self):
pass

def __new__(cls) -> PortManager:
@staticmethod
def get_single_instance() -> PortManager:
assert __class__ == PortManager__ThisHost
assert __class__.sm_single_instance_guard is not None

if __class__.sm_single_instance is None:
with __class__.sm_single_instance_guard:
__class__.sm_single_instance = super().__new__(cls)
assert __class__.sm_single_instance
if __class__.sm_single_instance is not None:
assert type(__class__.sm_single_instance) == __class__ # noqa: E721
return __class__.sm_single_instance

with __class__.sm_single_instance_guard:
if __class__.sm_single_instance is None:
__class__.sm_single_instance = __class__()
assert __class__.sm_single_instance is not None
assert type(__class__.sm_single_instance) == __class__ # noqa: E721
return __class__.sm_single_instance

Expand Down
2 changes: 1 addition & 1 deletiontestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -272,7 +272,7 @@ def _get_port_manager(os_ops: OsOperations) -> PortManager:
assert isinstance(os_ops, OsOperations)

if isinstance(os_ops, LocalOperations):
return PortManager__ThisHost()
return PortManager__ThisHost.get_single_instance()

# TODO: Throw the exception "Please define a port manager." ?
return PortManager__Generic(os_ops)
Expand Down
2 changes: 1 addition & 1 deletiontests/helpers/global_data.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,7 +39,7 @@ class OsOpsDescrs:
class PortManagers:
sm_remote_port_manager = PortManager__Generic(OsOpsDescrs.sm_remote_os_ops)

sm_local_port_manager = PortManager__ThisHost()
sm_local_port_manager = PortManager__ThisHost.get_single_instance()

sm_local2_port_manager = PortManager__Generic(OsOpsDescrs.sm_local_os_ops)

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp