Server Background Tasks and Modules

What I’m trying to do:
Trying to write a module that accepts two dictionaries of data and returns a dictionary of results so that I can call import this common code in two places: an excel creation routine, and a .pdf report generator.

What I’ve tried and what’s not working:
My excel and .pdf generators are background tasks because they take so long. I’ve written the ‘module’ as a server.callable… so when I import this in my .pdf generator background task… the module times out because it’s taking longer than 30 seconds. I can’t make this module a background task because my .pdf generator has to get the results…

How do create or include a module (I really want this to be code I can re-use) so that it does not time out? Perhaps my understanding of background tasks is flawed - I don’t think I can ‘call’ a background task and expect the calling code to simply ‘wait’ for the return value

Why write your module as server callable? It should just be a function that you import and call in the appropriate places? Unless I’m misunderstanding some context.

@dconnell I made an example of what @jshaffstall is talking about:

import_example

Is there something we are missing that does not work with background tasks?

So… I think the issue here is a lack of applied cognitive ability on my part… lemme take another crack at this.

OK, thanks for the assist… honestly without the ianbuywise example I would have never figured this out. I have it working and I’m smarter going forward.

1 Like