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

[#247] PortManager__Generic uses lock-dirs for reserved ports#255

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

Open
dmitry-lipetsk wants to merge9 commits intopostgrespro:master
base:master
Choose a base branch
Loading
fromdmitry-lipetsk:master-fix247--v001
Open
Changes from1 commit
Commits
Show all changes
9 commits
Select commitHold shift + click to select a range
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
NextNext commit
PortManager__Generic is refactored [consts, asserts]
  • Loading branch information
@dmitry-lipetsk
dmitry-lipetsk committedMay 7, 2025
commitc9b4bbf9a84b2f4f041e12afa8669f00287f9ec0
22 changes: 17 additions & 5 deletionstestgres/impl/port_manager__generic.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,9 @@


class PortManager__Generic(PortManager):
C_MIN_PORT_NUMBER = 1024
C_MAX_PORT_NUMBER = 65535

_os_ops: OsOperations
_guard: object
# TODO: is there better to use bitmap fot _available_ports?
Expand All@@ -20,11 +23,20 @@ class PortManager__Generic(PortManager):
_lock_dir: str

def __init__(self, os_ops: OsOperations):
assert __class__.C_MIN_PORT_NUMBER <= __class__.C_MAX_PORT_NUMBER

assert os_ops is not None
assert isinstance(os_ops, OsOperations)
self._os_ops = os_ops
self._guard = threading.Lock()
self._available_ports = set(range(1024, 65536))

self._available_ports = set(
range(__class__.C_MIN_PORT_NUMBER, __class__.C_MAX_PORT_NUMBER + 1)
)
assert len(self._available_ports) == (
(__class__.C_MAX_PORT_NUMBER - __class__.C_MIN_PORT_NUMBER) + 1
)

self._reserved_ports = set()
self._lock_dir = None

Expand DownExpand Up@@ -56,8 +68,8 @@ def reserve_port(self) -> int:
assert not (port in self._reserved_ports)
assert port in self._available_ports

assert port >=0
assert port <=65535
assert port >=__class__.C_MIN_PORT_NUMBER
assert port <=__class__.C_MAX_PORT_NUMBER

if not self._os_ops.is_port_free(port):
continue
Expand DownExpand Up@@ -86,8 +98,8 @@ def reserve_port(self) -> int:

def release_port(self, number: int) -> None:
assert type(number) == int # noqa: E721
assert number >=0
assert number <=65535
assert number >=__class__.C_MIN_PORT_NUMBER
assert number <=__class__.C_MAX_PORT_NUMBER

assert self._guard is not None
assert type(self._reserved_ports) == set # noqa: E721
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp