Skip to content

Enable using a threaded WSGI server #323

@delthas

Description

@delthas

Hi,

I'm making tests where I need to check the behavior of my application when there are two concurrent requests to my server, while one is sleeping:

  • T=0s Receive request 1 (start sleeping)
  • T=2s Receive request 2
  • T=2.1s Respond to request 2
  • T=5s Respond to request 1

(I can't just start two servers on two different ports, this has to be on the same port.)

This would normally mean just doing time.sleep in my handler for request 1; but this does not work because the WSGI server created by pytest-httpserver is not threaded:

https://github.com/csernazs/pytest-httpserver/blob/master/pytest_httpserver/httpserver.py#L745

(threaded=False, processes=1 by default)

It would be nice to enable the user to specify whether the underlying WSGI server should be threaded, ie adding a threaded named argument somewhere (in start() or in init()), then passing that flag to the WSGI server.

Would you accept such a PR? Or is there another way to achieve what I'm trying to do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions