How and why does QuickEdit mode in Command Prompt freeze applications?

This is very much by design. There’s no reasonable way a user can select text when your program keeps scrolling the content of the console window. So the console host program simply stops reading your stdout/stderr output and your program hangs until the user completes the operation. This can be changed, you’ll have to call … Read more

What is the correct way to make my PyQt application quit when killed from the console (Ctrl-C)?

17.4. signal — Set handlers for asynchronous events Although Python signal handlers are called asynchronously as far as the Python user is concerned, they can only occur between the “atomic” instructions of the Python interpreter. This means that signals arriving during long calculations implemented purely in C (such as regular expression matches on large bodies … Read more

Why can’t Unix programs have signals with meaningful program defined names (rather than USR1, etc)?

The signals available on an OS are defined by the OS (usually following POSIX) – they’re not “strings” but rather integer constants with standard names. USR1 and USR2 are the two signals that have no attached specific meaning – intended for whatever arbitrary use the developer wants. On your linux machine, read man 7 signal … Read more

POSIX threads and signals

What’s the best way to control which thread a signal is delivered to? As @zoli2k indicated, explicitly nominating a single thread to handle all signals you want handled (or a set of threads each with specific signal responsibilities), is a good technique. What is the best way to tell another thread (that might actually be … Read more

Django: signal when user logs in?

You can use a signal like this (I put mine in models.py) from django.contrib.auth.signals import user_logged_in def do_stuff(sender, user, request, **kwargs): whatever… user_logged_in.connect(do_stuff) See django docs: https://docs.djangoproject.com/en/dev/ref/contrib/auth/#module-django.contrib.auth.signals and here http://docs.djangoproject.com/en/dev/topics/signals/

Catch Ctrl+C / SIGINT and exit multiprocesses gracefully in python [duplicate]

The previously accepted solution has race conditions and it does not work with map and async functions. The correct way to handle Ctrl+C/SIGINT with multiprocessing.Pool is to: Make the process ignore SIGINT before a process Pool is created. This way created child processes inherit SIGINT handler. Restore the original SIGINT handler in the parent process … Read more

Calling pthread_cond_signal without locking mutex

If you do not lock the mutex in the codepath that changes the condition and signals, you can lose wakeups. Consider this pair of processes: Process A: pthread_mutex_lock(&mutex); while (condition == FALSE) pthread_cond_wait(&cond, &mutex); pthread_mutex_unlock(&mutex); Process B (incorrect): condition = TRUE; pthread_cond_signal(&cond); Then consider this possible interleaving of instructions, where condition starts out as FALSE: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)