signals

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. file init

不打扰是莪最后的温柔 提交于 2019-11-29 11:50:39
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. Exception appeared when I added: import signals in init .py file (apps/application/init.py) from models import Review in signals.py file (apps/application/signals.py) I want to send an http request when there is an insert in the model Review. So I need to import Review model (in the __init.py__ file) to execute the following code: @receiver (pre_save, sender = Review) def my_handler (sender, ** kwargs): .... In the Django's source , this is where the exception is comming from: def check_apps_ready(self): """Raise an exception

Why is post_save being raised twice during the save of a Django model?

喜欢而已 提交于 2019-11-29 11:46:19
问题 I am attaching a method to the post_save signal of my Django model. This way I can clear some cached items whenever the model is modified. The problem I am having is that the signal is being triggered twice when the model is saved. It doesn't necessarily hurt anything (the code will just gracefully error out) but it can't be right. A quick example, just printing the model to the console (using the dev server): from blog.models import Post from django.db.models import signals def purge_cache

How to send SIGINT signal from Java to an external process?

放肆的年华 提交于 2019-11-29 11:26:24
问题 I have a Java app that creates an external process and reads the process' stdout through an InputStream. I need to be able to kill the process when I am done with it. Is there a way to send a SIGINT signal to this process? (as if I pressed Ctrl+C from the console). The external process is not my code and I cannot modify it. 回答1: Are you running the external program as a java.lang.Process ? As the Process class has a destroy() method. 回答2: Can you send kill -SIGINT <pid> to the process (given

Django signals not working properly

半城伤御伤魂 提交于 2019-11-29 11:15:26
I'm trying to setup a signal so that when a valid form is saved, a function is ran to carry out a related task. My app structure is as follows; - events - helpers - __init__.py - status.py - models - signals - __init__.py - event.py - __init__.py - event.py - status.py - views - __init__.py - event.py I believe signals need to be imported as early as possible, before models, so at the top of models/__init__.py I've got from .signals import * . # views/event.py class AddEventView(CreateView): """ View for adding an Event. """ model = Event form_class = EventForm success_url = reverse_lazy(

What does SEGV_ACCERR mean?

大城市里の小女人 提交于 2019-11-29 10:54:45
问题 I am examining a few crashes that all have the signal SIGSEGV with the reason SEGV_ACCERR. After searching for SEGV_ACCERR, the closest thing I have found to a human readable explanation is: Invalid Permissions for object What does this mean in a more general sense? When would a SEGV_ACCERR arise? Is there more specific documentation on this reason? 回答1: This is an error that I have mostly seen on 64 bit iOS devices and can happen if multiple threads read and change a variable under ARC. For

How to convert signal name (string) to signal code?

╄→尐↘猪︶ㄣ 提交于 2019-11-29 10:25:36
I am writing a program that reads the name of the signal (e.g. SIGSTOP, SIGKILL etc) as a string from the command line and calls the kill() system call to send the signal. I was wondering if there is a simple way to convert the string to signal codes (in signal.h). Currently, I'm doing this by writing my own map that looks like this: signal_map["SIGSTOP"] = SIGSTOP; signal_map["SIGKILL"] = SIGKILL; .... But its tedious to write this for all signals. So, I was looking for a more elegant way, if it exists. Not sure if that is what you are loking for, but: strerror() converts a error code to the

Are std::signal and std::raise thread-safe?

一曲冷凌霜 提交于 2019-11-29 09:16:38
The C and C++ standards support the concept of signal. However, the C11 standard says that the function signal() cannot be called in multi-threaded environments, or the behavior is undefined. But I think the signal mechanism is by nature for multi-threaded environments. A quote from the C11 standard 7.14.1.1.7 "Use of this function in a multi-threaded program results in undefined behavior. The implementation shall behave as if no library function calls the signal function." Any explanations about this? The following code is self-evident. #include <thread> #include <csignal> using namespace std

What does g_signal_connect_swapped() do?

浪尽此生 提交于 2019-11-29 09:06:16
According to GObject reference g_signal_connect_swapped(instance, detailed_signal, c_handler, data); connects a GCallback function to a signal for a particular object. The instance on which the signal is emitted and data will be swapped when calling the handler. I don't quite get what this means. Does this mean that the data will point to the object pointed to by instance and instance will point to the object that was pointed to by data or am I making a mistake here? If former is the case then what is the logic behind this? You understand correctly. This allows you to do tricks like the

how to use “sigaltstack” in signal handler program?

早过忘川 提交于 2019-11-29 08:46:53
问题 did anyone who knows how to use the sigaltstack in a real signal handler program,a simple but complete code may be great help to me! thank you in advance! 回答1: Here is a minimal sample program that uses sigaltstack to catch infinite recursion. If you comment out the sigaltstack call or SA_ONSTACK flag, the signal handler will not be able to run because it has no stack left and the program will just crash. #define _XOPEN_SOURCE 700 #include <signal.h> #include <unistd.h> void handler(int sig)

write on closed connection doesn't generate sigpipe immediately

こ雲淡風輕ζ 提交于 2019-11-29 08:46:44
I've this problem with my server/client on C. If I close the server socket after a SIGINT, and then I try to write on this closed connection from the client, I've to do write two times before than client generates SIGPIPE. Shouldn't it generate it immediately? Is this a normal behaviour or something I need to fix? This is my code. I'm testing things on ubuntu, same PC, connecting via 127.0.0.1. server.c sigset_t set; struct sigaction sign; int sock_acc; int sock; void closeSig(){ close(sock_acc); close(sock); exit(1); } int main(){ sigemptyset(&set); sigaddset(&set, SIGINT); sig.sa_sigaction =