Skip to content
Open
Changes from all commits
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
15 changes: 8 additions & 7 deletions pythonping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


# this needs to be available across all thread usages and will hold ints
SEED_IDs = []
SEED_IDs = set()


def ping(target,
Expand Down Expand Up @@ -74,15 +74,16 @@ def ping(target,
# seed_id needs to be less than or equal to 65535 (as original code was seed_id = getpid() & 0xFFFF)
seed_id = randint(0x1, 0xFFFF)
if seed_id not in SEED_IDs:
SEED_IDs.append(seed_id)
SEED_IDs.add(seed_id)
break

try:
comm = executor.Communicator(target, provider, timeout, interval, socket_options=options, verbose=verbose, output=out,
seed_id=seed_id, source=source, repr_format=out_format)

comm = executor.Communicator(target, provider, timeout, interval, socket_options=options, verbose=verbose, output=out,
seed_id=seed_id, source=source, repr_format=out_format)
comm.run(match_payloads=match)

comm.run(match_payloads=match)

SEED_IDs.remove(seed_id)
finally:
SEED_IDs.remove(seed_id)

return comm.responses