Commit 5971df7bc98a696df2b710e784e0ed32bd1eaf59

Authored by Lucas Kanashiro
Committed by Sergio Oliveira
1 parent 011124d4

Add comment to reducer function on colab.signals

Signed-off-by: Lucas Moura <lucas.moura128@gmail.com>
Showing 1 changed file with 8 additions and 1 deletions   Show diff stats
colab/signals/signals.py
... ... @@ -7,8 +7,15 @@ registered_signals = {}
7 7 signal_instances = {}
8 8  
9 9  
10   -# Fix celery serialization for signal
11 10 def reducer(self):
  11 + '''
  12 + In order to send a signal to a celery task, it is necessary to pickle
  13 + the objects that will be used as parameters. However,
  14 + django.dispatch.Signal has an instance of threading.Lock, which is an
  15 + object that cannot be pickled. Therefore, this function changes the
  16 + pickle behaviour of Signal, making that only the providind_args of
  17 + Signal to be pickled.
  18 + '''
12 19 return (Signal, (self.providing_args,))
13 20 Signal.__reduce__ = reducer
14 21  
... ...