-
Notifications
You must be signed in to change notification settings - Fork 46
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
Issue closing down instance on Windows #16
Comments
* Assumes all other platforms work with sigint instead of sigterm * testcases are broken on Windows due to use of os.fork
Hi, I'm unable to get this to work still with the latest testing.postgresql build. Getting unsupported signal 2 still, is this fixed? |
I'm still getting this error on Windows with version 1.3.0. Any ideas? |
Using the master branch fixes the issue for me. 👍 |
Yes, master branch works for me as well! Would be great if the pypi version could be updated to include the windows-fix! |
Is there any danger in killing the process manually on windows instead of using
|
To chime in as well, I had the same issue as above and cloning from the master branch in the repo via Would be nice to get this fix into the PyPI version! EDIT - add the The full command is |
@tk0miya How can we get this fix into PyPi? |
Just FYI, I have long since given up on this module. I was happy to remove this as it was adding a lot of overhead (read time) to my tests, especially on Windows. |
What's going on is that the process termination signal being used to call The hack-workaround is to monkey patch db_test_env.py# pylint: disable=global-statement
import atexit
import os
import platform
import signal
from threading import Lock
import testing.postgresql
_IS_WINDOWS = platform.system() == "Windows"
_INITIALIZED = False
_LOCK = Lock()
def _db_test_env_teardown(postgresql: testing.postgresql.Postgresql) -> None:
"""Clears test database."""
global _INITIALIZED
with _LOCK:
assert _INITIALIZED
prev_sig_int = signal.SIGINT
try:
if _IS_WINDOWS:
# Hack for windows. Int signal is always 2 deep down in the
# call chain. So we monkey patch the SIGINT to SIGTERM for the
# duration of the call.
signal.SIGINT = signal.SIGTERM
postgresql.stop()
_INITIALIZED = False
finally:
if _IS_WINDOWS:
signal.SIGINT = prev_sig_int
def db_test_env_init(strict: bool = False) -> str:
"""Initializes test database."""
global _INITIALIZED
with _LOCK:
if _INITIALIZED:
if strict:
raise RuntimeError("Test database already initialized")
return os.environ["DB_URL"] or ""
postgresql = testing.postgresql.Postgresql()
url = postgresql.url()
os.environ["DB_URL"] = url
_INITIALIZED = True
atexit.register(_db_test_env_teardown, postgresql)
return url |
I'm working with Python 3.5.2 on WIndows 10.
Code like the following:
run does nothing..
Receiving the following error:
So its saying that
signal.SIGINT
is not supported.. is that a Windows thing??The text was updated successfully, but these errors were encountered: