-
Notifications
You must be signed in to change notification settings - Fork 413
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
Pyshark fails when run with Flask - tshark_process = existing_process or self.eventloop.run_until_complete(self._get_tshark_process()) #303
Comments
Hey stadelmannj, |
It is because python 3.7 only main thread can have EvenLoop, but flask request is solved in worker thread, so if you want to use pyshark in flask, you must work in main thread. I solved this by using python 2.7 and pyshark 0.3.3 |
Happened to run across this myself in another project that uses threads. Tried Python 3.6, 3.7, downgrading to pyshark 0.3.8, none of that helped. |
I was having random errors related to cap = pyshark.FileCapture(file). |
@mgoffin @solidossnakos - Can you post code where that happens? |
I can't share the code short of the instantiation of the object as it's a private code base at the moment. But to describe it...we have a core process that spawns multiple long-running threads and in one of those threads is where we instantiate the try:
cap = FileCapture(
data,
display_filter=display_filter,
decryption_key=decryption_key,
encryption_type=encryption_type,
)
asyncio.get_child_watcher().attach_loop(cap.eventloop)
except Exception as e:
print(e) This triggers the exception and prints |
I get the same issue as @mgoffin when using a |
I'm still getting this issue now, but I found a workaround if your setup allows it. |
Is there any update on this issue? |
I am having the same error. Are there any fixes? |
Hi, @SadeghKrmi |
I too am facing this issue in my code after moving to python3. The same code works in python2.7. None of the suggested workarounds or fixes seem to work for me. Looks like pyshark really dropped the ball on this one. How can you not have you module built to be thread safe? |
Hi,
running Pyshark under Flask on Linux (with Python 3.6.6) always fails, even with the most simple capture reading and for loop.
it only works if cap = pyshark.FileCapture(file) is run under the main program (before flask; which does not work in my case since I need to re-read the file while being in Flask)
the same code works fine on Python 3.7 for Windows.
error msg:
i reduced the code to the minimum to prove it always fails, even w/o complex display-filter for extensive for-loops.
Code :
any help would be appreciated since we really need to run this on Linux and not Windows
The text was updated successfully, but these errors were encountered: