Question

How can I use asyncio in Python-Caller/Creator?


Badge +4

I wonder if aynone has expericence with using asyncio in python FME?

I've been trying to decorate with some asyncio.coroutine and do some async def, but I cannot grasp the whole picture on how to combine a syncronized FME project with an async library like asyncio.

Anyone who would share their knowledge on this topic would be Awsome!

Paal


12 replies

Userlevel 4

My initial thought is that it might be difficult, as you say, to reconcile the synchronous nature of FME with an asynchronous process.

Perhaps if you can describe a bit further what you're trying to accomplish, someone might have an idea.

Badge +4

Hi and thanks for feedback.

I was just looking for a way in general to create a queue from a list, or stream of features and then do some async prosessing like get requests and them output the features as they get back from the requests.

Userlevel 4

I'm not sure if it's relevant for your use case, but FME Server has a pretty neat websockets interface:

http://docs.safe.com/fme/2018.1/html/FME_Server_Documentation/Content/ReferenceManual/WebSocket-Server.htm

Badge +4

Yes, and thanks I do know that FME Server provide async, but I really want to build this inside FME Desktop.

Badge +4

I have now explored this option in FME 2019 With Python3.7 and its quite easy to do Async GET requests.

If anyone is interested I can try to bundle it inside a custom transformer?

Userlevel 4

I have now explored this option in FME 2019 With Python3.7 and its quite easy to do Async GET requests.

If anyone is interested I can try to bundle it inside a custom transformer?

I'm definitely interested.

Badge +4

I'm definitely interested.

Hey @david_r, I'm unable to make the transformer pass the testsuit on hub.safe.com, since the hub is using a FME Server which runs python3.6, when the package Depends on Python 3.7 syntax. I could send it directly to you if you are still interested. Its only been tested on Windows.

Userlevel 4

Hey @david_r, I'm unable to make the transformer pass the testsuit on hub.safe.com, since the hub is using a FME Server which runs python3.6, when the package Depends on Python 3.7 syntax. I could send it directly to you if you are still interested. Its only been tested on Windows.

Hi Paal, tusen takk, that's very kind of you. You can reach me on .

Badge

Hi Paal

I'm quite interested in this solution too. Any chance you can reach out to me as well please?

Thanks

Ken

Badge +4

Hi Paal

I'm quite interested in this solution too. Any chance you can reach out to me as well please?

Thanks

Ken

Hi Ken,

Nice to see you again!

 

Basically I used aiohttp external pypi lib and asyncio to do the requests from a pythonCaller.

 

Its been a while since I visited the solution, but what is your main task?

 

The new HttpCaller has async builtin and is very fast!

 

Badge

Hi Paal, nice to hear from you again too!

Thanks for your answer!

In fact when I though about it I just need an asynchronous python process. So this can be done with subprocess in python (which I've used before years ago!).

All the best,

Ken

 

 

Badge +4

Hi Paal, nice to hear from you again too!

Thanks for your answer!

In fact when I though about it I just need an asynchronous python process. So this can be done with subprocess in python (which I've used before years ago!).

All the best,

Ken

 

 

Thanks!

 

Im not sure how well subprocess works with asyncio. If the process does calculations it wont help to run it async, maybe if it read files. There is though a library called aiofiles, which does that.

 

Well if you want to look at some code, you can open the AsyncHttpCaller from hub. Its password is Integrations.

 

I havnent played with it in a while, I guess its pretty advanced logic. And Hard to keep nice tidy.

 

 

Reply