polyswarmclient.producer
¶
Submodules¶
Package Contents¶
-
class
polyswarmclient.producer.
Producer
(client, redis_uri, queue, time_to_post, bounty_filter=None, confidence_modifier=None, rate_limit=None)[source]¶
-
class
polyswarmclient.producer.
JobRequest
[source]¶ -
polyswarmd_uri
:str¶
-
guid
:str¶
-
index
:int¶
-
uri
:str¶
-
artifact_type
:int¶
-
duration
:int¶
-
metadata
:Optional[Dict[str, Any]]¶
-
chain
:str¶
-
ts
:int¶
-
key
¶
-
is_expired
(self, now=None)¶
-
get_artifact_type
(self)¶
-
asdict
(self)¶
-
-
class
polyswarmclient.producer.
JobResponse
[source]¶ -
index
:int¶
-
bit
:bool¶
-
verdict
:bool¶
-
confidence
:float¶
-
metadata
:str¶
-
asdict
(self)¶
-
-
class
polyswarmclient.producer.
JobProcessor
(redis: Redis, queue: str, confidence_modifier: Optional[ConfidenceModifier], period: float = 0.25, redis_error_callback: Optional[Callable[[], Coroutine]] = None)[source]¶ Keeps track pending jobs, and polls the PendingJob results every period of time (.5 seconds)
-
redis_uri
:str¶
-
confidence_modifier
:Optional[ConfidenceModifier]¶
-
queue
:str¶
-
period
:float¶
-
pending_jobs
:Dict[str, PendingJob]¶
-
job_lock
:Optional[asyncio.Lock]¶
-
redis
:Optional[Redis]¶
-
task
¶
-
reset_callback
¶
-
stop
(self)¶ Stop processing jobs
-
-
class
polyswarmclient.producer.
PendingJob
(key: str, jobs: List[JobRequest], future: Future)[source]¶ A wrapper around a list of Jobs that are processing in the backend
-
key
:str¶
-
jobs
:List[JobRequest]¶
-
results
:Dict[int, ScanResult]¶
-
future
:Future¶
-
times
(self)¶
-
time_ratios
(self)¶
-
__store_job_response
(self, response: JobResponse, confidence_modifier: Optional[ConfidenceModifier])¶ Converts a JobResponse to ScanResult with modified confidence. Stores at the correct index in internal results
- Parameters
response – JobResponse to conver
confidence_modifier – an optional ConfidenceModifier to potentially change the confidence
- Returns
-
is_done
(self)¶ Checks all things to see if it is done :return: true if expired, or has all results
-
__is_expired
(self)¶ Returns true if any of the jobs are expired
-
__has_all_results
(self)¶ Returns true if all the jobs have a result
-
__finish
(self)¶ Set the results in the future and mark done
-