question

Tomi Kosunen avatar image
0 Likes"
Tomi Kosunen asked Kavika F commented

Synchronous Python command

Hi. How do execute synchronous Python command? I'm sending queries to a server from Python command. It takes some time to get an answer from the server so I need to stop the FlexSim clock for that time. In Http request I can use request.sendAndWait(); but how the same is done with Python?

In the example, the server response delay is modelled with sleep command in Python code. The Processor is asking for a process time from Python.

testWait.fsm

time_funktio.py

FlexSim 23.1.1
pythonsynchronous
testwait.fsm (41.5 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Kavika F avatar image
0 Likes"
Kavika F answered Kavika F commented

Hey @Tomi Kosunen, there are a few resources I can point you to to help you setup your queries. Here's a post I made a few months back about someone wanting to run an experimenter, updating parameters through python and a server/client connection. It uses the serverreceive() command which has the option to block the model (i.e., the server) from running until it receives a message from your python code (i.e., the client). There are some custom User Commands to simplify the process in the model from the post, so be sure to take a look at those.

1682528885202.png


1682528885202.png (3.6 KiB)
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.