Request consumer
PConsumer
consumer class that consumes the requests and returns the responses of the ClashOfClans API
:ivar queue: the request_queue where the requests are enqueued :type queue: Queue :ivar r_p_s: allowed number of requests that can be done with one consumer in one second :type r_p_s: int :ivar url: the base URL for the requests :type url: str
Source code in pyclasher/client/request_consumer.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
__init__(queue, token, requests_per_s, request_timeout, url)
initialisation of the request consumer
:param queue: the request_queue where the requests are enqueued :type queue: Queue :param token: one ClashOfClans API token :type token: str :param requests_per_s: allowed number of requests that can be done with one consumer in one second :type requests_per_s: int :param request_timeout: seconds until the request is cancelled due to a timeout :type request_timeout: float :param url: the base URL for the requests :type url: str :return: None :rtype: None
Source code in pyclasher/client/request_consumer.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
close()
async
asynchronous method that closed the consumer
:return: None :rtype: None
Source code in pyclasher/client/request_consumer.py
72 73 74 |
|
consume()
async
asynchronous method that is used as a consuming task that consumes requests forever until stopped
:return: None :rtype: None .. note:: uses an infinite while loop, only run it as an asyncio task
Source code in pyclasher/client/request_consumer.py
59 60 61 62 63 64 65 66 67 68 69 70 |
|