Is it safe to use "hg serve"?

Didly Bom didlybom at gmail.com
Wed Jun 2 14:13:01 UTC 2010


On Wed, Jun 2, 2010 at 4:07 PM, Augie Fackler <durin42 at gmail.com> wrote:

>
> On Jun 2, 2010, at 9:06 AM, Didly Bom wrote:
>
>  On Wed, Jun 2, 2010 at 3:49 PM, Augie Fackler <durin42 at gmail.com> wrote:
>>
>>
>>> On Jun 2, 2010, at 2:12 AM, Martin Geisler wrote:
>>>
>>>  Augie Fackler <durin42 at gmail.com> writes:
>>>>
>>>>  On Jun 1, 2010, at 12:25 PM, Martin Geisler wrote:
>>>>>
>>>>>  When people say that the server is not recommended for publishing, I
>>>>>> believe they mean that
>>>>>>
>>>>>> * there is no access control, as you've found out
>>>>>>
>>>>>> * it uses the standard Python web server module which I guess isn't
>>>>>> as robust or scalable as Apache or IIS
>>>>>>
>>>>>
>>>>> Notably, it's not threaded at all - it's a completely synchronous
>>>>> server and can handle only one request at a time.
>>>>>
>>>>
>>>> It's funny, I was about to write that I believed it was single-threaded,
>>>> but then I looked at the code and found this in hgweb/server.py:
>>>>
>>>> try:
>>>>    from threading import activeCount
>>>>    _mixin = SocketServer.ThreadingMixIn
>>>> except ImportError:
>>>>    if hasattr(os, "fork"):
>>>>        _mixin = SocketServer.ForkingMixIn
>>>>    else:
>>>>        class _mixin:
>>>>            pass
>>>>
>>>> # ...
>>>>
>>>> class MercurialHTTPServer(object, _mixin, BaseHTTPServer.HTTPServer):
>>>>
>>>> and hoped that would mean that we do have a threaded or forking server.
>>>> If this is not used for 'hg serve', when is it then used?
>>>>
>>>
>>> Hm, I could be wrong. I was basing this assumption on the fact that I
>>> seem
>>> to get dismal performance out of 'hg serve' as compared to spawning.
>>> Here's
>>> my spawning entry point, for what it's worth:
>>>
>>> % cat spawnhg.py
>>> #!/usr/bin/env python
>>> """Support for running hgweb as a WSGI app inside spawning."""
>>> import os
>>> HERE = os.path.dirname(__file__)
>>> #from mercurial import demandimport; demandimport.enable()
>>> from mercurial.hgweb.hgwebdir_mod import hgwebdir
>>> application = hgwebdir(os.path.join(HERE, 'hgweb.config'))
>>>
>>> It assumes there's an hgweb.config in the same directory as the file. Run
>>> as:
>>> spawn spawnhg.application
>>>
>>> I just use the defaults for worker processes and the like.
>>>
>>>
>>>  Thanks for the tip, Augie. I will give it a try.
>>
>> Since the spawning library is really small (~22 KB), if its performance is
>> so much better than the builtin server, could it make sense to use it
>> instead of the standard lib BaseHttpServer module to create the built-in
>> web
>> server?
>>
>> Angel
>>
>
> Not really - it's an extra dependency beyond Python, and it requires
> greenlet and eventlet as well.
>

OK, I see. That is a pity, but I will give it a try anyway.

Angel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20100602/8bedf0fa/attachment.html>


More information about the Mercurial mailing list