isunbejo / exaproxy

Automatically exported from code.google.com/p/exaproxy
Other
0 stars 1 forks source link

Running with Python < 2.7 #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run exaproxy with Python < 2.7
2.
3.

What is the expected output? What do you see instead?
Running exaproxy, instead you get:
[...]
  File "/home/ec2-user/exaproxy-1.1.2/lib/exaproxy/util/cache.py", line 3, in <module>
    from collections import OrderedDict
ImportError: cannot import name OrderedDict

What version of the product are you using? On what operating system?
Linux (Amazon AMI), Python 2.6.8, exaproxy 1.1.2

Please provide any additional information below.
exaproxy script checks for different versions of Python, but uses OrderedDict 
from collections (lib/exaproxy/util/cache.py) which was introduced in Python 
2.7.

http://docs.python.org/2/library/collections.html#collections.OrderedDict

Personally believe the required Python version should be mentioned.

Original issue reported on code.google.com by luka.fur...@gmail.com on 13 Aug 2013 at 3:38

GoogleCodeExporter commented 9 years ago
A possible solution to make exaproxy compatible with Python 2.6 would be use of 
backported ordereddict implementation:

diff --git a/lib/exaproxy/util/cache.py b/lib/exaproxy/util/cache.py
index 42e8a7a..a2dfc58 100644
--- a/lib/exaproxy/util/cache.py
+++ b/lib/exaproxy/util/cache.py
@@ -1,6 +1,12 @@
 # encoding: utf-8

-from collections import OrderedDict
+try:
+       from collections import OrderedDict
+except ImportError:
+       try:
+               from ordereddict import OrderedDict
+       except ImportError:
+
 from time import time

 class TimeCache (dict):

Tested in the same environment as original issue was reported.

Original comment by luka.fur...@gmail.com on 14 Aug 2013 at 3:22

GoogleCodeExporter commented 9 years ago
Hello Luka,

Thank you for the bug report.

We have committed a patch to support the backported ordereddict module and it 
will be included in the next release version of the proxy.

Original comment by iwantmyname on 14 Aug 2013 at 8:16

GoogleCodeExporter commented 9 years ago
reopened - the copy of the ordered dict implementation of Python 2.7 is not 
included in ExaBGP therefore this will still fail.

The proposed patch is as well incomplete: application.py needs to be changed to 
check for 2.6 and not 2.4 (this code was copied from ExaBGP).

Furthermore, I would argue that we should not support any version under 2.7.5 
(as there is some bugs which AFAICR do affect ExaProxy under high load). Sorry 
I can not be more specific.

Original comment by thomas.mangin on 14 Aug 2013 at 10:35

GoogleCodeExporter commented 9 years ago
Hi,

The diff pasted was more of a proposed solution than a patch as it leaves 
cache.py in a broken state (missing stuff after the final except).
If you decide to support 2.6 I would be more than happy to write a complete 
patch (including application.py, exaproxy start script ...).

Cheers,
Luka

Original comment by luka.fur...@gmail.com on 15 Aug 2013 at 9:02

GoogleCodeExporter commented 9 years ago
Please re-open on Github issue tracker if it still matters to you.

Original comment by thomas.mangin on 11 Oct 2013 at 11:16