Skip to content

Commit

Permalink
Introduced RetryChoiceListFactory to deal with parallelism issues (#91)…
Browse files Browse the repository at this point in the history
… (#92)

* Introduced RetryChoiceListFactory to deal with parallelism issues

* Fixes

* Fixes2

* Added exponential retry
  • Loading branch information
mnocon committed Nov 2, 2023
1 parent 138b37c commit 2bf3ca1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/bundle/Subscriber/StartScenarioSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Facebook\WebDriver\Exception\UnknownErrorException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\Store\FlockStore;

class StartScenarioSubscriber implements EventSubscriberInterface
{
Expand Down Expand Up @@ -50,7 +52,20 @@ public function resizeWindow(BeforeScenarioTested $event): void

$session = $this->kernel->getContainer()->get('behat.mink.default_session');
if (!$session->isStarted()) {
$session->start();

$store = new FlockStore(sys_get_temp_dir());
$factory = new LockFactory($store);

$lock = $factory->createLock('session-start');

if ($lock->acquire(true)) {
try {
$session->start();
}
finally {
$lock->release();
}
}
}

$this->executeWithRetry(function () use ($session): void {
Expand Down

0 comments on commit 2bf3ca1

Please sign in to comment.