Skip to content
Permalink
Browse files
Remove (probably unnecessary) copy_func usage
  • Loading branch information
nyalldawson committed Dec 5, 2016
1 parent d03d0a5 commit cc702c9c81923c130c281d5d3ad51dfbffd6a478
Showing with 2 additions and 12 deletions.
  1. +2 −12 python/core/__init__.py
@@ -187,24 +187,14 @@ def __exit__(self, ex_type, ex_value, traceback):
return False


def copy_func(f):
"""Based on http://stackoverflow.com/a/6528148/190597 (Glenn Maynard)"""
g = types.FunctionType(f.__code__, f.__globals__, name=f.__name__,
argdefs=f.__defaults__,
closure=f.__closure__)
g = functools.update_wrapper(g, f)
g.__kwdefaults__ = f.__kwdefaults__
return g


class QgsTaskWrapper(QgsTask):

def __init__(self, description, flags, function, on_finished, *args, **kwargs):
QgsTask.__init__(self, description, flags)
self.args = args
self.kwargs = kwargs
self.function = copy_func(function)
self.on_finished = copy_func(on_finished) if on_finished else None
self.function = function
self.on_finished = on_finished
self.returned_values = None
self.exception = None

0 comments on commit cc702c9

Please sign in to comment.