Skip to content

Commit

Permalink
request timeout as a separate config param
Browse files Browse the repository at this point in the history
  • Loading branch information
nekhbet committed Jan 25, 2024
1 parent 903b810 commit dc7c81a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/SuperPREDTargetPrediction.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ class SuperPREDTargetPrediction
private string $userAgent = '';
private string $SMILES_code = '';

public function __construct()
private int $requestTimeout;

public function __construct(int $requestTimeout = 20)
{
$this->userAgent = $this->userAgentsPool[rand(0, count($this->userAgentsPool) - 1)];
$this->requestTimeout = $requestTimeout;
$this->userAgent = $this->userAgentsPool[rand(0, count($this->userAgentsPool) - 1)];
}

public function setUserAgent(string $ua): SuperPREDTargetPrediction
Expand Down Expand Up @@ -131,7 +134,7 @@ public function getRawTargets(): array
private function doPostCall(string $url, array $post_data): ResponseInterface
{
$client = new Client([
'timeout' => 20,
'timeout' => $this->requestTimeout,
]);

return $client->request('POST', $url, [
Expand Down

0 comments on commit dc7c81a

Please sign in to comment.