Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pygeoapi serve runs pygeoapi web application twice #1504

Closed
ricardogsilva opened this issue Jan 18, 2024 · 3 comments · Fixed by #1505
Closed

pygeoapi serve runs pygeoapi web application twice #1504

ricardogsilva opened this issue Jan 18, 2024 · 3 comments · Fixed by #1505
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ricardogsilva
Copy link
Member

Description
The pygeoapi serve command invokes the web application twice, as can be seen here:

ctx.forward(serve_flask)
ctx.invoke(serve_flask)

According to the click docs, context.forward() and context.invoke() are somewhat similar:

A mentioned in the docs, both ctx.forward() and ctx.invoke() result in the underlying function being called, which in pygeoapi's case means the call to serve_flask will run twice.

This can be seen if you run the pygeoapi server with pygeoapi serve and then try to stop it by pressing <CTRL+C> - You will need to press this key combination twice, as the first time it stops the first invocation (i.e. the call to ctx.forward() and proceeds to run pygeoapi server again, as it reaches the second invocation (i.e. the call to ctx.invoke()).

export PYGEOAPI_CONFIG=my-config.yml 
export PYGEOAPI_OPENAPI=my-openapi.yml

pygeoapi serve

# in order to exit you need to press CTRL+C twice
@ricardogsilva ricardogsilva added the bug Something isn't working label Jan 18, 2024
@doublebyte1
Copy link
Contributor

@ricardogsilva Yes, this is a really annoying, because if we want to attach a debugger to the pygeoapi process, we are never sure which one to choose. It is also draining resources. Do you have any suggestions on how to fix this?

@ricardogsilva
Copy link
Member Author

@doublebyte1

The fix would simply be to remove one of the calls, either ctx.forward() or ctx.invoke() - I haven't reviewed it in depth to see which one should be preferred.

However, I believe this would not be the reason for troubles when attaching a debugger, as each pygeoapi invocation is done in sequence, meaning the second one only starts running when one decides to press CTRL+C, which ends the first one and then starts the second

@doublebyte1
Copy link
Contributor

@ricardogsilva got it, then it's a different problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants