0

I have a web service that creates images from geographic features and return it to a map using django framework. This is a tiling map service (TMS)

The web sercive is called through an url such: http://host.com/TMS/map_id/x/y/z.png where map_id, x, y and z are variables used to generate the images.

This url call a python function which return the images in a map client (OpenLayers). When moving in the map the user call a bunch of requests on this webservice like http://host.com/tiling/1/0/1/1.png, http://host.com/tiling/1/1/0/1.png, etc

I would like to use eventlet to thread the function of this webservice in order to generate images in parallel instead of one by a time.

Can someone help me doing this by providing cue about how to listen to a specific url (TMS url) and how to start threads on the function. Thanks a lot.

4

1 回答 1

2

Eventlet 邮件列表上相同线程的副本:

最简单的方法是将后端服务器更改为 gunicorn 或 spawning 或 eventlet.wsgi。

所有这些(可能还有其他一些)都能够在单独的绿色线程中为每个连接或请求提供服务。

请注意,如果请求处理受 CPU 限制,绿色线程将无济于事。

如何在 eventlet.wsgi 服务器下运行 Django?

Django 没有什么特别之处,它从 1.4 开始就是一个常规的 WSGI 应用程序。 https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/

现在需要做什么来绿色线程我的网络服务的功能?我正在为 Windows 运行进程监视器工具,我看到该函数实际上是在单个线程上运行的。

你完成了。每个请求都在一个单独的绿色线程中提供服务。根据定义1,绿色线程在进程之外是不可见的。(这意味着进程监控工具也看不到绿色线程)

于 2013-12-19T07:54:50.530 回答