clue / reactphp-sqlite

Async SQLite database, lightweight non-blocking process wrapper around file-based database extension (ext-sqlite3), built on top of ReactPHP.
https://clue.engineering/2019/introducing-reactphp-sqlite
MIT License
51 stars 10 forks source link

Not able to Prevent the ReactPHP's Factory Instantiation #28

Closed teleclient closed 4 years ago

teleclient commented 4 years ago

Hi. How can I prevent ReactPHP from instantiating the React\EventLoop\Factory.

I have no const/envVar AMP_REACT_ADAPTER_DISABLE_FACTORY_OVERRIDE

PHP 7.4 Win10 & Linux

===

<?php  
require DIR . '/vendor/autoload.php';  
$loop    = Amp\ReactAdapter\ReactAdapter::get();  
$factory = new Clue\React\SQLite\Factory($loop);  
$db      = $factory->openLazy('users.db'); //<= error  
exit;  

===

"minimum-stability": "dev",  
"require": {  
    "clue/reactphp-sqlite": "dev-master",  
    "amphp/react-adapter":  "dev-master"  
}`  

===


C:\devphp\reactphp_sqlite_test>php sqlite.php
PHP Fatal error: Uncaught Error: React\EventLoop\Factory::create() has been overridden by amphp/react-adapter to prevent you from accidentally creating two event loop instances. Use Amp\ReactAdapter\ReactAdapter::get() instead of React\EventLoop\Factory::create() to ensure everything is running on the same event loop. You may set a constant or environment variable named AMP_REACT_ADAPTER_DISABLE_FACTORY_OVERRIDE to disable this protection or open an issue at https://github.com/amphp/react-adapter if you're unsure on the right way forward. in C:\devphp\reactphp_sqlite_test\vendor\amphp\react-adapter\etc\Factory.php:24
Stack trace:
#0 C:\devphp\reactphp_sqlite_test\vendor\clue\reactphp-sqlite\res\sqlite-worker.php(30): React\EventLoop\Factory::create()
#1 {main}
  thrown in C:\devphp\reactphp_sqlite_test\vendor\amphp\react-adapter\etc\Factory.php on line 24
clue commented 4 years ago

@teleclient This is an interesting one :+1:

Your seeing error output from the child worker process which always uses ReactPHP's event-loop which your amphp/react-adapter dependency doesn't like. It looks like you might better redirect this question to this project and/or see if it helps to set the environment variable the error mentions.

I believe this has been answered, so I'm closing this for now. Please report back or come back with more details if this problem persists and we can reopen this :+1: