##// END OF EJS Templates
sessions: patch baker to take expire time for redis for auto session cleanup.
marcink -
r4484:7bc1ace5 default
parent child Browse files
Show More
@@ -0,0 +1,18 b''
1 diff -rup Beaker-1.9.1-orig/beaker/session.py Beaker-1.9.1/beaker/session.py
2 --- Beaker-1.9.1-orig/beaker/session.py 2020-04-10 10:23:04.000000000 +0200
3 +++ Beaker-1.9.1/beaker/session.py 2020-04-10 10:23:34.000000000 +0200
4 @@ -156,6 +156,14 @@ def __init__(self, request, id=None, invalidate_corrupt=False,
5 if timeout and not save_accessed_time:
6 raise BeakerException("timeout requires save_accessed_time")
7 self.timeout = timeout
8 + # We want to pass timeout param to redis backend to support expiration of keys
9 + # In future, I believe, we can use this param for memcached and mongo as well
10 + if self.timeout is not None and self.type == 'ext:redis':
11 + # The backend expiration should always be a bit longer (I decied to use 2 minutes) than the
12 + # session expiration itself to prevent the case where the backend data expires while
13 + # the session is being read (PR#153)
14 + self.namespace_args['timeout'] = self.timeout + 60 * 2
15 +
16 self.save_atime = save_accessed_time
17 self.use_cookies = use_cookies
18 self.cookie_expires = cookie_expires No newline at end of file
@@ -0,0 +1,26 b''
1 diff -rup Beaker-1.9.1-orig/beaker/ext/redisnm.py Beaker-1.9.1/beaker/ext/redisnm.py
2 --- Beaker-1.9.1-orig/beaker/ext/redisnm.py 2018-04-10 10:23:04.000000000 +0200
3 +++ Beaker-1.9.1/beaker/ext/redisnm.py 2018-04-10 10:23:34.000000000 +0200
4 @@ -30,9 +30,10 @@ class RedisNamespaceManager(NamespaceManager):
5
6 clients = SyncDict()
7
8 - def __init__(self, namespace, url, **kw):
9 + def __init__(self, namespace, url, timeout=None, **kw):
10 super(RedisNamespaceManager, self).__init__(namespace)
11 self.lock_dir = None # Redis uses redis itself for locking.
12 + self.timeout = timeout
13
14 if redis is None:
15 raise RuntimeError('redis is not available')
16 @@ -68,6 +69,8 @@ def has_key(self, key):
17
18 def set_value(self, key, value, expiretime=None):
19 value = pickle.dumps(value)
20 + if expiretime is None and self.timeout is not None:
21 + expiretime = self.timeout
22 if expiretime is not None:
23 self.client.setex(self._format_key(key), int(expiretime), value)
24 else:
25
26
@@ -1,279 +1,281 b''
1 # Overrides for the generated python-packages.nix
1 # Overrides for the generated python-packages.nix
2 #
2 #
3 # This function is intended to be used as an extension to the generated file
3 # This function is intended to be used as an extension to the generated file
4 # python-packages.nix. The main objective is to add needed dependencies of C
4 # python-packages.nix. The main objective is to add needed dependencies of C
5 # libraries and tweak the build instructions where needed.
5 # libraries and tweak the build instructions where needed.
6
6
7 { pkgs
7 { pkgs
8 , basePythonPackages
8 , basePythonPackages
9 }:
9 }:
10
10
11 let
11 let
12 sed = "sed -i";
12 sed = "sed -i";
13
13
14 localLicenses = {
14 localLicenses = {
15 repoze = {
15 repoze = {
16 fullName = "Repoze License";
16 fullName = "Repoze License";
17 url = http://www.repoze.org/LICENSE.txt;
17 url = http://www.repoze.org/LICENSE.txt;
18 };
18 };
19 };
19 };
20
20
21 in
21 in
22
22
23 self: super: {
23 self: super: {
24
24
25 "appenlight-client" = super."appenlight-client".override (attrs: {
25 "appenlight-client" = super."appenlight-client".override (attrs: {
26 meta = {
26 meta = {
27 license = [ pkgs.lib.licenses.bsdOriginal ];
27 license = [ pkgs.lib.licenses.bsdOriginal ];
28 };
28 };
29 });
29 });
30
30
31 "beaker" = super."beaker".override (attrs: {
31 "beaker" = super."beaker".override (attrs: {
32 patches = [
32 patches = [
33 ./patches/beaker/patch-beaker-lock-func-debug.diff
33 ./patches/beaker/patch-beaker-lock-func-debug.diff
34 ./patches/beaker/patch-beaker-metadata-reuse.diff
34 ./patches/beaker/patch-beaker-metadata-reuse.diff
35 ./patches/beaker/patch-beaker-improved-redis.diff
36 ./patches/beaker/patch-beaker-improved-redis-2.diff
35 ];
37 ];
36 });
38 });
37
39
38 "cffi" = super."cffi".override (attrs: {
40 "cffi" = super."cffi".override (attrs: {
39 buildInputs = [
41 buildInputs = [
40 pkgs.libffi
42 pkgs.libffi
41 ];
43 ];
42 });
44 });
43
45
44 "cryptography" = super."cryptography".override (attrs: {
46 "cryptography" = super."cryptography".override (attrs: {
45 buildInputs = [
47 buildInputs = [
46 pkgs.openssl
48 pkgs.openssl
47 ];
49 ];
48 });
50 });
49
51
50 "gevent" = super."gevent".override (attrs: {
52 "gevent" = super."gevent".override (attrs: {
51 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
53 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
52 # NOTE: (marcink) odd requirements from gevent aren't set properly,
54 # NOTE: (marcink) odd requirements from gevent aren't set properly,
53 # thus we need to inject psutil manually
55 # thus we need to inject psutil manually
54 self."psutil"
56 self."psutil"
55 ];
57 ];
56 });
58 });
57
59
58 "future" = super."future".override (attrs: {
60 "future" = super."future".override (attrs: {
59 meta = {
61 meta = {
60 license = [ pkgs.lib.licenses.mit ];
62 license = [ pkgs.lib.licenses.mit ];
61 };
63 };
62 });
64 });
63
65
64 "testpath" = super."testpath".override (attrs: {
66 "testpath" = super."testpath".override (attrs: {
65 meta = {
67 meta = {
66 license = [ pkgs.lib.licenses.mit ];
68 license = [ pkgs.lib.licenses.mit ];
67 };
69 };
68 });
70 });
69
71
70 "gnureadline" = super."gnureadline".override (attrs: {
72 "gnureadline" = super."gnureadline".override (attrs: {
71 buildInputs = [
73 buildInputs = [
72 pkgs.ncurses
74 pkgs.ncurses
73 ];
75 ];
74 patchPhase = ''
76 patchPhase = ''
75 substituteInPlace setup.py --replace "/bin/bash" "${pkgs.bash}/bin/bash"
77 substituteInPlace setup.py --replace "/bin/bash" "${pkgs.bash}/bin/bash"
76 '';
78 '';
77 });
79 });
78
80
79 "gunicorn" = super."gunicorn".override (attrs: {
81 "gunicorn" = super."gunicorn".override (attrs: {
80 propagatedBuildInputs = [
82 propagatedBuildInputs = [
81 # johbo: futures is needed as long as we are on Python 2, otherwise
83 # johbo: futures is needed as long as we are on Python 2, otherwise
82 # gunicorn explodes if used with multiple threads per worker.
84 # gunicorn explodes if used with multiple threads per worker.
83 self."futures"
85 self."futures"
84 ];
86 ];
85 });
87 });
86
88
87 "nbconvert" = super."nbconvert".override (attrs: {
89 "nbconvert" = super."nbconvert".override (attrs: {
88 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
90 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
89 # marcink: plug in jupyter-client for notebook rendering
91 # marcink: plug in jupyter-client for notebook rendering
90 self."jupyter-client"
92 self."jupyter-client"
91 ];
93 ];
92 });
94 });
93
95
94 "ipython" = super."ipython".override (attrs: {
96 "ipython" = super."ipython".override (attrs: {
95 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
97 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
96 self."gnureadline"
98 self."gnureadline"
97 ];
99 ];
98 });
100 });
99
101
100 "lxml" = super."lxml".override (attrs: {
102 "lxml" = super."lxml".override (attrs: {
101 buildInputs = [
103 buildInputs = [
102 pkgs.libxml2
104 pkgs.libxml2
103 pkgs.libxslt
105 pkgs.libxslt
104 ];
106 ];
105 propagatedBuildInputs = [
107 propagatedBuildInputs = [
106 # Needed, so that "setup.py bdist_wheel" does work
108 # Needed, so that "setup.py bdist_wheel" does work
107 self."wheel"
109 self."wheel"
108 ];
110 ];
109 });
111 });
110
112
111 "mysql-python" = super."mysql-python".override (attrs: {
113 "mysql-python" = super."mysql-python".override (attrs: {
112 buildInputs = [
114 buildInputs = [
113 pkgs.openssl
115 pkgs.openssl
114 ];
116 ];
115 propagatedBuildInputs = [
117 propagatedBuildInputs = [
116 pkgs.libmysql
118 pkgs.libmysql
117 pkgs.zlib
119 pkgs.zlib
118 ];
120 ];
119 });
121 });
120
122
121 "psycopg2" = super."psycopg2".override (attrs: {
123 "psycopg2" = super."psycopg2".override (attrs: {
122 propagatedBuildInputs = [
124 propagatedBuildInputs = [
123 pkgs.postgresql
125 pkgs.postgresql
124 ];
126 ];
125 meta = {
127 meta = {
126 license = pkgs.lib.licenses.lgpl3Plus;
128 license = pkgs.lib.licenses.lgpl3Plus;
127 };
129 };
128 });
130 });
129
131
130 "pycurl" = super."pycurl".override (attrs: {
132 "pycurl" = super."pycurl".override (attrs: {
131 propagatedBuildInputs = [
133 propagatedBuildInputs = [
132 pkgs.curl
134 pkgs.curl
133 pkgs.openssl
135 pkgs.openssl
134 ];
136 ];
135
137
136 preConfigure = ''
138 preConfigure = ''
137 substituteInPlace setup.py --replace '--static-libs' '--libs'
139 substituteInPlace setup.py --replace '--static-libs' '--libs'
138 export PYCURL_SSL_LIBRARY=openssl
140 export PYCURL_SSL_LIBRARY=openssl
139 '';
141 '';
140
142
141 meta = {
143 meta = {
142 license = pkgs.lib.licenses.mit;
144 license = pkgs.lib.licenses.mit;
143 };
145 };
144 });
146 });
145
147
146 "pyramid" = super."pyramid".override (attrs: {
148 "pyramid" = super."pyramid".override (attrs: {
147 meta = {
149 meta = {
148 license = localLicenses.repoze;
150 license = localLicenses.repoze;
149 };
151 };
150 });
152 });
151
153
152 "pyramid-debugtoolbar" = super."pyramid-debugtoolbar".override (attrs: {
154 "pyramid-debugtoolbar" = super."pyramid-debugtoolbar".override (attrs: {
153 meta = {
155 meta = {
154 license = [ pkgs.lib.licenses.bsdOriginal localLicenses.repoze ];
156 license = [ pkgs.lib.licenses.bsdOriginal localLicenses.repoze ];
155 };
157 };
156 });
158 });
157
159
158 "pysqlite" = super."pysqlite".override (attrs: {
160 "pysqlite" = super."pysqlite".override (attrs: {
159 propagatedBuildInputs = [
161 propagatedBuildInputs = [
160 pkgs.sqlite
162 pkgs.sqlite
161 ];
163 ];
162 meta = {
164 meta = {
163 license = [ pkgs.lib.licenses.zlib pkgs.lib.licenses.libpng ];
165 license = [ pkgs.lib.licenses.zlib pkgs.lib.licenses.libpng ];
164 };
166 };
165 });
167 });
166
168
167 "python-ldap" = super."python-ldap".override (attrs: {
169 "python-ldap" = super."python-ldap".override (attrs: {
168 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
170 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
169 pkgs.openldap
171 pkgs.openldap
170 pkgs.cyrus_sasl
172 pkgs.cyrus_sasl
171 pkgs.openssl
173 pkgs.openssl
172 ];
174 ];
173 });
175 });
174
176
175 "python-pam" = super."python-pam".override (attrs: {
177 "python-pam" = super."python-pam".override (attrs: {
176 propagatedBuildInputs = [
178 propagatedBuildInputs = [
177 pkgs.pam
179 pkgs.pam
178 ];
180 ];
179
181
180 # TODO: johbo: Check if this can be avoided, or transform into
182 # TODO: johbo: Check if this can be avoided, or transform into
181 # a real patch
183 # a real patch
182 patchPhase = ''
184 patchPhase = ''
183 substituteInPlace pam.py \
185 substituteInPlace pam.py \
184 --replace 'find_library("pam")' '"${pkgs.pam}/lib/libpam.so.0"'
186 --replace 'find_library("pam")' '"${pkgs.pam}/lib/libpam.so.0"'
185 '';
187 '';
186
188
187 });
189 });
188
190
189 "python-saml" = super."python-saml".override (attrs: {
191 "python-saml" = super."python-saml".override (attrs: {
190 buildInputs = [
192 buildInputs = [
191 pkgs.libxml2
193 pkgs.libxml2
192 pkgs.libxslt
194 pkgs.libxslt
193 ];
195 ];
194 });
196 });
195
197
196 "dm.xmlsec.binding" = super."dm.xmlsec.binding".override (attrs: {
198 "dm.xmlsec.binding" = super."dm.xmlsec.binding".override (attrs: {
197 buildInputs = [
199 buildInputs = [
198 pkgs.libxml2
200 pkgs.libxml2
199 pkgs.libxslt
201 pkgs.libxslt
200 pkgs.xmlsec
202 pkgs.xmlsec
201 pkgs.libtool
203 pkgs.libtool
202 ];
204 ];
203 });
205 });
204
206
205 "pyzmq" = super."pyzmq".override (attrs: {
207 "pyzmq" = super."pyzmq".override (attrs: {
206 buildInputs = [
208 buildInputs = [
207 pkgs.czmq
209 pkgs.czmq
208 ];
210 ];
209 });
211 });
210
212
211 "urlobject" = super."urlobject".override (attrs: {
213 "urlobject" = super."urlobject".override (attrs: {
212 meta = {
214 meta = {
213 license = {
215 license = {
214 spdxId = "Unlicense";
216 spdxId = "Unlicense";
215 fullName = "The Unlicense";
217 fullName = "The Unlicense";
216 url = http://unlicense.org/;
218 url = http://unlicense.org/;
217 };
219 };
218 };
220 };
219 });
221 });
220
222
221 "docutils" = super."docutils".override (attrs: {
223 "docutils" = super."docutils".override (attrs: {
222 meta = {
224 meta = {
223 license = pkgs.lib.licenses.bsd2;
225 license = pkgs.lib.licenses.bsd2;
224 };
226 };
225 });
227 });
226
228
227 "colander" = super."colander".override (attrs: {
229 "colander" = super."colander".override (attrs: {
228 meta = {
230 meta = {
229 license = localLicenses.repoze;
231 license = localLicenses.repoze;
230 };
232 };
231 });
233 });
232
234
233 "pyramid-beaker" = super."pyramid-beaker".override (attrs: {
235 "pyramid-beaker" = super."pyramid-beaker".override (attrs: {
234 meta = {
236 meta = {
235 license = localLicenses.repoze;
237 license = localLicenses.repoze;
236 };
238 };
237 });
239 });
238
240
239 "pyramid-mako" = super."pyramid-mako".override (attrs: {
241 "pyramid-mako" = super."pyramid-mako".override (attrs: {
240 meta = {
242 meta = {
241 license = localLicenses.repoze;
243 license = localLicenses.repoze;
242 };
244 };
243 });
245 });
244
246
245 "repoze.lru" = super."repoze.lru".override (attrs: {
247 "repoze.lru" = super."repoze.lru".override (attrs: {
246 meta = {
248 meta = {
247 license = localLicenses.repoze;
249 license = localLicenses.repoze;
248 };
250 };
249 });
251 });
250
252
251 "python-editor" = super."python-editor".override (attrs: {
253 "python-editor" = super."python-editor".override (attrs: {
252 meta = {
254 meta = {
253 license = pkgs.lib.licenses.asl20;
255 license = pkgs.lib.licenses.asl20;
254 };
256 };
255 });
257 });
256
258
257 "translationstring" = super."translationstring".override (attrs: {
259 "translationstring" = super."translationstring".override (attrs: {
258 meta = {
260 meta = {
259 license = localLicenses.repoze;
261 license = localLicenses.repoze;
260 };
262 };
261 });
263 });
262
264
263 "venusian" = super."venusian".override (attrs: {
265 "venusian" = super."venusian".override (attrs: {
264 meta = {
266 meta = {
265 license = localLicenses.repoze;
267 license = localLicenses.repoze;
266 };
268 };
267 });
269 });
268
270
269 "supervisor" = super."supervisor".override (attrs: {
271 "supervisor" = super."supervisor".override (attrs: {
270 patches = [
272 patches = [
271 ./patches/supervisor/patch-rlimits-old-kernel.diff
273 ./patches/supervisor/patch-rlimits-old-kernel.diff
272 ];
274 ];
273 });
275 });
274
276
275 # Avoid that base packages screw up the build process
277 # Avoid that base packages screw up the build process
276 inherit (basePythonPackages)
278 inherit (basePythonPackages)
277 setuptools;
279 setuptools;
278
280
279 }
281 }
General Comments 0
You need to be logged in to leave comments. Login now