1

I change the original file to add a new routing, but the changes don't work even if I restart the gunicorn server. What is the reason for this? Is it Git, Visual Code, my remote Linux, VirtualanEnv ... or what? I'm deeply confused

enter image description here

BeeWay Inc
  • 47
  • 1
  • 5
  • 1
    I don't know why your updates are not working, but I would suggest changing your tags: [tag:python] would only be appropriate if you were asking about some Python programming language aspects, [tag:linux] would only be appropriate if you were asking about Linux APIs and ABIs and such, [tag:git] would only be appropriate if you were asking how to use Git itself, and [tag:falcon] seems to be about the Falcon programming language, not a Falcon framework for gunicorn. The one tag you should probably *add* is [tag:gunicorn]. – torek May 15 '21 at 22:32
  • 1
    If you still cannot get it to work, I would also suggest to paste the whole minimal application source code example, so that others can check (and hopefully reproduce) exactly the same problem you are experiencing. – Vytas May 23 '21 at 19:47

1 Answers1

2

It is hard to what the reason is, as there are many "moving" parts (the IDE, Gunicorn, etc); but I cannot reproduce your issue.

Maybe the server was not reloaded or restarted, against your expectation, and you are simply still dealing with Gunicorn running old code? If you are sure you have restarted your debug server, then it should not matter; otherwise make sure to pass the --reload option, see also: gunicorn autoreload on source change.

As to the application itself, the following MRE works for me:

import falcon


class Contest:
    def on_get(self, req, resp, contest_id):
        resp.media = {
            'contest_id': contest_id,
            'uri_template': req.uri_template,
        }

    def on_get_ping(self, req, resp):
        resp.content_type = falcon.MEDIA_TEXT
        resp.text = 'PONG\n'


application = falcon.App()

contest = Contest()
application.add_route('/api/v1/ping', contest, suffix='ping')
application.add_route('/api/v1/member/contest/{contest_id:int}', contest)
application.add_route('/api/v1/member/contest/new/{contest_id:int}', contest)

When running with gunicorn --reload --access-logfile - test:application, I can even comment out routes or bring them back, save, and the changes are reflected in the application's behaviour.

Checking the end points in question:

$ curl http://localhost:8000/api/v1/ping
PONG
$ curl http://localhost:8000/api/v1/member/contest/1
{"contest_id": 1, "uri_template": "/api/v1/member/contest/{contest_id:int}"}
$ curl http://localhost:8000/api/v1/member/contest/new/2
{"contest_id": 2, "uri_template": "/api/v1/member/contest/new/{contest_id:int}"}
Vytas
  • 754
  • 5
  • 14
  • Your option is good for deep validation. I used tmux in my work and used one of the parts of the project, as a pip module, and at some point my launches were mixed and I had to reset all processes and rebuild the virtual environment. But the ultimate reason is still not clear why this happened. – BeeWay Inc May 26 '21 at 07:53