Starting module tasks
Chris Johns (8262) 242 posts |
As some will know, I’ve developed a TaskRunner module. Mainly to support running subprocesses in python but it could be useful elsewhere too. I have been updating it (mainly to not soak up CPU) and trying to get it in order for a release. However, I’m not totally clear how you should start a module task, other than by double-clicking on the module. In the case of Python, I can’t “just” *RMRun it, and *RMLoad will load the module but not start the wimp task. I’ve added a Desktop_TaskRunner command to do that, so the sequence would be something to decide if the module needs loading, if it does *RMLoad it then *WimpTask Desktop_TaskRunner. Is this the “right way” or is there a better one? I don’t want to insist on the module being there and check load it in !Run – you can run python without it if you don’t use subprocess. I’d therefore like to load it when subprocess is imported. |
Julie Stamp (8365) 474 posts |
I’ve seen you mention TaskRunner before. What does it do? |
Chris Johns (8262) 242 posts |
It’s a way to run things using TaskWindow (the module, not the actual windows provided by an editor) and control it from a SWI interface. This allows the parent task to be running in a task window (in the more usual sense). It was created to support Python’s ‘subprocess’ (with limitations). |
Julie Stamp (8365) 474 posts |
Neat |
Jeffrey Lee (213) 6048 posts |
The way I prefer to do it is via TaskManager_StartTask. You can call it in your module’s init routine. Issues:
|
Julie Stamp (8365) 474 posts |
Is that the same as doing *StartDesktopTask? |
Chris Johns (8262) 242 posts |
@Jeffray – Thanks -that seems much neater. I think I can live with those limits: The SWI interface side can queue up things until the task has started. Obviously it won’t start running unitl later, but “created but not running” is a valid state. I can’t see anyone using python3 on RISC OS 3.x systems, it’s apparntly slow on an Iyonix so who knows what it’d be like on anything older. I assume convention would be the command is “Desktop_TaskRunner” ? |
Jeffrey Lee (213) 6048 posts |
Yes (*StartDesktopTask is just a wrapper around TaskManager_StartTask)
Yes. Although if a module doesn’t need to do anything special I guess there’s no reason why it can’t just tell TaskManager_StartTask to “RMRun MyModule” directly. |
David J. Ruck (33) 1637 posts |
Chris, please can you make sure it uses Wimp_PollIdle before release, chewing half a million null polls a second is not helpful. |
Chris Johns (8262) 242 posts |
I’m actually using a poll word now to get around that problem. The main reason for the release is to fix the null poll CPU soaking. |