Bug 30258 - UMC-Server: Add decorator for simple functions with background tasks
UMC-Server: Add decorator for simple functions with background tasks
Status: RESOLVED WONTFIX
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 4.1
Other Linux
: P5 enhancement (vote)
: ---
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-01 20:01 CET by Dirk Wiesenthal
Modified: 2019-02-27 18:05 CET (History)
2 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
best: Patch_Available+


Attachments
Proof of concept for a threading decorator (13.13 KB, patch)
2013-02-01 20:01 CET, Dirk Wiesenthal
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Wiesenthal univentionstaff 2013-02-01 20:01:37 CET
Created attachment 5034 [details]
Proof of concept for a threading decorator

At the moment, adding a "non-blocking" function to a module is quite painful.
It is often done this way:

def nonblock(self, request):
  var1 = request.options.get('var1')
  self.finished(request.id, var1 * 2)
  def _thread(var):
    do_some_expensive_stuff(var)
  def _finished(thread, result):
    if isinstance(result, BaseException):
      MODULE.warn('Exception during expensive: %s' % (str(result))
  thread = notifier.threads.Simple('nonblock', notifier.Callback(_thread,
var1), _finished)
  thread.run()

In UCS 3.1 we have added a decorator for simple tasks (@simple_response), but
it is limited when it comes to background tasks that should not block the whole
module. We should extend its function to be able to spawn a thread after
sending a response easily.

Idea:

@simple_response
def nonblock(self, var1):
  yield var1 * 2
  do_some_expensive_stuff(var1)

Proof of concept attached (does not work very well together with @log at the
moment). Used App Center for demonstration.

The function could be helpful in a couple of modules (requiring nonblocking
actions was the #1 show stopper to use @simple_response at a larger scale). I
have been working on one third-party module and this could have used it, too.
Comment 1 Stefan Gohmann univentionstaff 2019-01-03 07:19:29 CET
This issue has been filled against UCS 4.1. The maintenance with bug and security fixes for UCS 4.1 has ended on 5st of April 2018.

Customers still on UCS 4.1 are encouraged to update to UCS 4.3. Please contact
your partner or Univention for any questions.

If this issue still occurs in newer UCS versions, please use "Clone this bug" or simply reopen the issue. In this case please provide detailed information on how this issue is affecting you.