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

Timer can only be used in workerman running environment #1084

Open
joanhey opened this issue Jan 8, 2025 · 6 comments
Open

Timer can only be used in workerman running environment #1084

joanhey opened this issue Jan 8, 2025 · 6 comments

Comments

@joanhey
Copy link
Contributor

joanhey commented Jan 8, 2025

Testing Adapterman

image

And also don't show where is used the Timer, that create the error.

PD: Timer use in Adapterman
https://github.com/search?q=repo%3Ajoanhey%2FAdapterMan%20timer&type=code

@walkor
Copy link
Owner

walkor commented Jan 8, 2025

throw new RuntimeException('Timer can only be used in workerman running environment');

@joanhey
Copy link
Contributor Author

joanhey commented Jan 8, 2025

Yes I check the class, I found the Exception.
But why fail ?

PD: also checking the Timer use in Adapterman, I found a double session clean. That I need to fix.

@walkor
Copy link
Owner

walkor commented Jan 8, 2025

The timer can only be used in the Workerman runtime environment and cannot be used independently.

@joanhey
Copy link
Contributor Author

joanhey commented Jan 8, 2025

When I said : don't show where is used the Timer, that create the error.

Is that the Exception don't show where was used the Timer that create the error.

@walkor
Copy link
Owner

walkor commented Jan 8, 2025

It’s possible that you caught an exception but didn’t output the call stack. You can directly print the call stack information or log it in Timer.php. The code is similar to this:

        if (!Worker::getAllWorkers()) {
            echo new \Exception('dump stack');
            file_put_contents('/tmp/workerman_timer_dump', (string) new \Exception('dump stack'));
            throw new RuntimeException('Timer can only be used in workerman running environment');
        }

@joanhey
Copy link
Contributor Author

joanhey commented Jan 8, 2025

I created a new branch for test with Workerman5, till I fixed.

And new Adapterman v0.7 with all the changes in code and fixes for PHP8.4. ( I only tried if it was possible also with Workerman5)

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