Skip to content

Commit

Permalink
Remove (probably unnecessary) copy_func usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 5, 2016
1 parent d03d0a5 commit cc702c9
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions python/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cc702c9

Please sign in to comment.