signals

How to gracefully terminate an asyncio script with Ctrl-C?

How to gracefully terminate an asyncio script with Ctrl-C? Question: I’ve read every post I could find about how to gracefully handle a script with an asyncio event loop getting terminated with Ctrl-C, and I haven’t been able to get any of them to work without printing one or more tracebacks as I do so. …

Total answers: 2

Python SIGINT not terminating calling shell

Python SIGINT not terminating calling shell Question: When running Python from a Linux shell (same behavior observed in both bash and ksh), and generating a SIGINT with a Ctl-C keypress, I have discovered behavior that I am unable to understand, and which has frustrated me considerably. When I press Ctl-C, the Python process appropriately terminates, …

Total answers: 3

Django: disconnect a post_save signal to avoid recursion

Django: disconnect a post_save signal to avoid recursion Question: This is my model: class Paper(models.Model): … collection = models.ForeignKey(Collection, on_delete=models.CASCADE) rang = models.IntegerField(default=0) class Meta: ordering = [‘collection’,’rang’] When saving the model, I want it to update all the ‘rang’ fields in each object of the model so that they increase by 10. I use …

Total answers: 3

Understanding scipy deconvolve

Understanding scipy deconvolve Question: I’m trying to understand scipy.signal.deconvolve. From the mathematical point of view a convolution is just the multiplication in fourier space so I would expect that for two functions f and g: Deconvolve(Convolve(f,g) , g) == f In numpy/scipy this is either not the case or I’m missing an important point. Although …

Total answers: 2

Exiting a tkinter app with Ctrl-C and catching SIGINT

Exiting a tkinter app with Ctrl-C and catching SIGINT Question: Ctrl-C/SIGTERM/SIGINT seem to be ignored by tkinter. Normally it can be captured again with a callback. This doesn’t seem to be working, so I thought I’d run tkinter in another thread since its mainloop() is an infinite loop and blocks. I actually also want to …

Total answers: 4

Django pre_save signal: how do I know if it is Insert or Update

Django pre_save signal: how do I know if it is Insert or Update Question: I’m working in a pre_save signal of a model and I don’t know how to check if the record is a INSERT or UPDATE. Code below (doesn’t work properly): @receiver(pre_save, sender=Person) def pre_save_person(sender, instance, **kwargs): if not instance.pk: print ‘INSERT !!!!!!’ …

Total answers: 3

PyQt proper use of emit() and pyqtSignal()

PyQt proper use of emit() and pyqtSignal() Question: I am reading through some documentation on PyQt5 to come up with a simple signal-slot mechanism. I have come to a halt due to a design consideration. Consider the following code: import sys from PyQt5.QtCore import (Qt, pyqtSignal) from PyQt5.QtWidgets import (QWidget, QLCDNumber, QSlider, QVBoxLayout, QApplication) class …

Total answers: 2

How can i use signals in django bulk create

How can i use signals in django bulk create Question: I have this code Task.objects.bulk_create(ces) Now this is my signal @receiver(pre_save, sender=Task) def save_hours(sender, instance, *args, **kwargs): logger.debug(‘test’) Now this signal is not triggered in bulk create I am using django 1.8 Asked By: user3214546 || Source Answers: As mentioned bulk_create does not trigger these …

Total answers: 2

Can I manually trigger signals in Django?

Can I manually trigger signals in Django? Question: I’ve written some signals in my Django app that are supposed to send out an email when a particular model instance is created or modified, but the signal receiver function doesn’t seem to be responding; at any rate, I’m not getting any emails through (although I have …

Total answers: 1

Ignoring Bash pipefail for error code 141

Ignoring Bash pipefail for error code 141 Question: Setting the bash pipefail option (via set -o pipefail) allows the script to fail if a non-zero error is caught where there is a non-zero error in any step of a pipe. However, we are running into SIGPIPE errors (error code 141), where data is written to …

Total answers: 5