question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: signal only works in main thread

See original GitHub issue

Hi, I used in Django runserver (dev) and uwsgi (production), same exception raised. It’s due to signal cannot be used in non-main thread.

Currently I have to monkey-patch HAS_SIGNAL = True to HAS_SIGNAL = False in f5/bigip/__init__.py. Hope there will be an option to disable signal use. Thanks.

File "/usr/local/lib/python2.7/site-packages/f5/bigip/__init__.py", line 114, in post_configuration_setup
   self._get_tmos_version()
 File "/usr/local/lib/python2.7/site-packages/f5/bigip/__init__.py", line 120, in _get_tmos_version
   signal.signal(SIGALRM, timeout_handler)
ValueError: signal only works in main thread

I put my code in Django views to get results from my GTM. It only works when I pass --noload --nothreading to Django runserver.

Django:

django-admin runserver

uwsgi:

uwsgi --ini uwsgi-docker.ini

#######################
# content of uwsgi-docker.ini
#######################
[uwsgi]
projectname = xxx
base = /home/user/xxx


# Django-related settings
# the base directory (full path)
chdir           = %(base)
# Django's wsgi file
module          = xxx.wsgi:application

master          = true
processes       = 8
threads         = 2
enable-threads  = true
socket          = 0.0.0.0:8000
vacuum          = true

env = DJANGO_SETTINGS_MODULE=%(projectname).settings_env.prod
pythonpath = %(base)
pythonpath = %(base)/common_libs
pythonpath = %(base)/xxx
logto = %(base)/logs/uwsgi.log
buffer-size = 32768
# set max log file to about 100MB
log-maxsize = 100000000
log-backupname = %(base)/logs/uwsgi.log.last

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
caphrim007commented, Aug 13, 2018

@jobec this friday

0reactions
caphrim007commented, Aug 22, 2018

@jobec this is now available

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: signal only works in main thread - Stack Overflow
Python signal handlers are always executed in the main Python thread, even if the signal was received in another thread. This means that...
Read more >
signal only works in main thread of the main interpreter #1
I am getting this error "signal only works in main thread of the main interpreter". Can you please explain it to me, how...
Read more >
ValueError('signal only works in main thread') - W&B Help
I'm running a hyper parameter sweep using PL and Weights and Biases's framework. Running on a GPU on Google Colab which causes all...
Read more >
Issue 38904: "signal only works in main thread" in main thread
The problem for both modules is that the Python runtime may have actually been initialized in a different thread, which is the actual...
Read more >
Django : ValueError: signal only works in main thread - YouTube
Django : ValueError : signal only works in main thread - Django - mod_wsgi [ Beautify Your Computer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found