Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMP library blocks Coroutine #52

Open
4khobta opened this issue Jul 7, 2023 · 1 comment
Open

SNMP library blocks Coroutine #52

4khobta opened this issue Jul 7, 2023 · 1 comment

Comments

@4khobta
Copy link

4khobta commented Jul 7, 2023

Good day. Help to understand, the php-snmp library is not supported by Swoole Coroutine ? Because asynchrony is blocked, and requests are executed in turn.
But work in tests like sleep, exec, file_get_contents, etc.

Maybe there is a solution to solve this issue?
Thanks

<?php
use function Swoole\Coroutine\go;
use function Swoole\Coroutine\run;

run(function () {
    for ($i = 1; $i < 100; ++$i) {
        go(function () use ($i) {
            $snmp = new \SNMP(\SNMP::VERSION_2c, '10.10.0.' . $i, 'public');
            $snmp->get('.1.3.6.1.2.1.1.3.0');
            var_dump($snmp);
        });
    }
});
@4khobta 4khobta changed the title SNMP library blocking Coroutine SNMP library blocks Coroutine Jul 7, 2023
@mdger
Copy link

mdger commented Jul 7, 2023

Swoole supports asynchronous IO by hooking native PHP libraries like curl, file_get_contents etc.

See https://openswoole.com/docs/modules/swoole-coroutine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants