ThrottleStatus
#
- class biotite.database.pubchem.ThrottleStatus(count: ..., time: ..., service: ...)[source]#
Bases:
object
This class gives information about the dynamic request throttling of Pubchem.
Typically, objects of this class are created from responses of the Pubchem sever using
from_response()
, so that the the throttle statuses can be read from that object.Furthermore, this class provides the
wait_if_busy()
method, that halts the execution for a short time at high loads to ensure adherence to Pubchem usage policies.- Parameters:
- countfloat
A value between 0 and (typically) 1 that indicates the current load of this user due to the number of requests. If the value exceeds 1, server requests will be blocked.
- timefloat
A value between 0 and (typically) 1 that indicates the current load of this user due to the running time of requests. If the value exceeds 1, server requests will be blocked.
- servicefloat
A value between 0 and (typically) 1 that indicates the current general load of the server. If the value exceeds 1, the server is overloaded.
- Attributes:
- count, time, servicefloat
Read-only attributes for the parameters given above.
- static from_response(response)#
Extract the throttle status from a Pubchem server response.
- Parameters:
- responserequests.Response
The response from the request to the Pubchem server.
- Returns:
- throttle_statusThrottleStatus
The extracted throttle status.
- wait_if_busy(threshold=0.5, wait_time=1.0)#
Halt the execution for a given number of seconds, if the current request time or count of this user exceeds the given threshold.
- Parameters:
- thresholdfloat, optional
A value between 0 and 1. If the load of either the request time or count exceeds this value the execution is halted.
- wait_timefloat, optional
The time in seconds the execution will halt, if the threshold is exceeded.