Commit 59f8cbad authored by Mikhail Karnevskiy's avatar Mikhail Karnevskiy
Browse files

use set instead of list

parent 3bb9c78d
Pipeline #6331 passed with stage
in 1 minute and 1 second
......@@ -210,12 +210,11 @@ class AsapoSender:
def get_ids_to_acknowledge(self, out_id):
id_to_acknowledge = []
for in_id in self._ids_to_acknowledge:
if out_id in self._ids_to_acknowledge[in_id]:
if len(self._ids_to_acknowledge[in_id]) == 1:
id_to_acknowledge.append(in_id)
else:
self._ids_to_acknowledge[in_id].remove(out_id)
for in_id, ack_ids in self._ids_to_acknowledge.items():
ack_ids.discard(out_id)
if not ack_ids:
id_to_acknowledge.append(in_id)
for in_id in id_to_acknowledge:
del self._ids_to_acknowledge[in_id]
return id_to_acknowledge
......
......@@ -8,6 +8,13 @@ from AsapoWorker.errors import ConfigurationError
log = logging.getLogger(__name__)
def to_set(a):
if a is None or isinstance(a, set):
return a
else:
return set(a)
@Configurable
class Worker:
sender = Config(
......@@ -76,7 +83,7 @@ class Worker:
def send(self, data, metadata, acknowledge=[], ack_dependencies=None):
if self.sender:
self.sender.send_data(
data, metadata, acknowledge=acknowledge, ack_dependencies=ack_dependencies)
data, metadata, acknowledge=acknowledge, ack_dependencies=to_set(ack_dependencies))
else:
raise ConfigurationError(
"Worker wants to send data, but no sender configured!")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment