Opened on 03/19/2015 at 05:30:58 AM

Closed on 03/24/2015 at 07:47:55 AM

Last modified on 03/25/2015 at 10:38:21 AM

#2169 closed change (fixed)

Unify development and production implementation of multiplexer

Reported by: fhd Assignee: sebastian
Priority: Unknown Milestone:
Module: Sitescripts Keywords:
Cc: sebastian, trev, matze Blocked By:
Blocking: Platform: Unknown
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):

http://codereview.adblockplus.org/6209629180657664

Description (last modified by sebastian)

Background

We're currently using Flask for the sitescripts development server, and a raw WSGI app running as FastCGI via flup in production. This is problematic, because things that work fine in development (e.g. responses are automatically encoded as utf-8) don't work in production.

What to change

Unify the multiplexer implementation into a common WSGI app, used both in production and by the development server using werkzeug.serving if installed, falling back to wsgiref.simple_server.

Attachments (0)

Change History (10)

comment:1 Changed on 03/19/2015 at 05:33:09 AM by fhd

  • Cc sebastian trev added

Not Ready yet, needs discussing.

I'd prefer the first option: Sure, it adds some magic we might not need. On the other hand, some of that magic is actually useful (e.g. how Flask handles utf-8 responses), and it's, how I see it, the only way that will make our development and production environment nearly identical.

comment:2 Changed on 03/19/2015 at 05:34:28 AM by fhd

  • Cc matze added

comment:3 Changed on 03/19/2015 at 06:07:32 AM by fhd

  • Summary changed from Use the same logic in development and production to Use a similar HTTP layer in development and production

comment:4 follow-up: Changed on 03/19/2015 at 07:35:54 AM by sebastian

There is no point in using Flask the way multiplexer is currently implemented. Since URL routing as well as response handling is implemented from scratch. The reason our development server still automatically encodes unicode objects is a bug in werkzeug.serving which relies on BaseHttpServer which does that magic.

So if you want to take advantage of Flask you should replace the multiplexer, using Flask's URL routing mechanism and Response objects instead. Fine with me, as long as you adapt all scripts currently using multiplexer, and make sure they are properly tested.

Otherwise, I'd suggest to use werkzeug.serving.run_simple() directly with a wrapper raising an exception if unicode is send for our development environment.

comment:5 in reply to: ↑ 4 Changed on 03/23/2015 at 02:29:56 PM by trev

Replying to sebastian:

The reason our development server still automatically encodes unicode objects is a bug in werkzeug.serving which relies on BaseHttpServer which does that magic.

That was my mistake - I was testing it with the CMS test server, yet missed that it was encoding responses elsewhere. So both werkzeug.serving and wsgiref don't encode Unicode automatically which is correct.

I dislike the idea of relying of something as complicated as Flask instead of the trivial framework currently used by sitescripts, also given the amount of unnecessary changes it will require. So my suggestion would be using werkzeug.serving.run_simple() for the test server with a fallback to wsgiref like we've done for #2196. This will bring us back to "pure WSGI" and hopefully no more compatibility issues.

Getting rid of the different host processes will be more tricky. It seems that uWSGI supports running both as a standalone HTTP and a FastCGI server (in addition to the probably more efficient uWSGI protocol). However, switching to that on our servers will likely be a lengthy process. Also, I'm not sure whether installing it is all that easy on all platforms.

comment:6 Changed on 03/23/2015 at 04:17:45 PM by sebastian

  • Description modified (diff)
  • Owner set to sebastian
  • Ready set
  • Summary changed from Use a similar HTTP layer in development and production to Unify development and production implementation of multiplexer

comment:7 Changed on 03/23/2015 at 04:21:07 PM by sebastian

  • Review URL(s) modified (diff)

comment:8 Changed on 03/23/2015 at 07:31:05 PM by trev

  • Status changed from new to reviewing

comment:9 Changed on 03/24/2015 at 07:47:55 AM by sebastian

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:10 Changed on 03/25/2015 at 10:36:04 AM by sebastian

  • Verified working unset

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from sebastian.
 
Note: See TracTickets for help on using tickets.