Klaus Demo bjoern / 05ceb26
Fix #158 Jonas Haag 3 months ago
4 changed file(s) with 28 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
1414 #define _PEP3333_BytesLatin1_FromUnicode(u) PyUnicode_AsLatin1String(u)
1515 #define _PEP3333_String_FromUTF8String(data) PyUnicode_FromString(data)
1616 #define _PEP3333_String_FromLatin1StringAndSize(data, len) PyUnicode_DecodeLatin1(data, len, "replace")
17 #define _PEP3333_String_FromFormat(...) PyUnicode_FromFormat(__VA_ARGS__)
1718 #define _PEP3333_String_GET_SIZE(u) PyUnicode_GET_LENGTH(u)
1819 #define _PEP3333_String_Concat(u1, u2) PyUnicode_Concat(u1, u2)
1920
2829 #define _PEP3333_Bytes_Resize(bytes, len) _PyString_Resize(bytes, len)
2930 #define _PEP3333_BytesLatin1_FromUnicode(u) (Py_INCREF(u),u)
3031 #define _PEP3333_String_FromUTF8String(data) PyString_FromString(data) // Assume UTF8
32 #define _PEP3333_String_FromFormat(...) PyString_FromFormat(__VA_ARGS__)
3133 #define _PEP3333_String_GET_SIZE(u) PyString_GET_SIZE(u)
3234
3335 static PyObject* _PEP3333_String_FromLatin1StringAndSize(const char* data, Py_ssize_t len)
347347 PyDict_SetItemString(wsgi_base_dict, "SERVER_NAME", server_info->host);
348348
349349 if (server_info->port == Py_None) {
350 PyDict_SetItemString(wsgi_base_dict, "SERVER_PORT", PyUnicode_FromFormat(""));
350 PyDict_SetItemString(wsgi_base_dict, "SERVER_PORT", PyString_FromFormat(""));
351351 } else {
352 PyDict_SetItemString(wsgi_base_dict, "SERVER_PORT", PyUnicode_FromFormat("%i", server_info->port));
352 PyDict_SetItemString(wsgi_base_dict, "SERVER_PORT", PyString_FromFormat("%i", server_info->port));
353353 }
354354 } else {
355355 /* SERVER_NAME is required, but not usefull with UNIX type sockets */
356 PyDict_SetItemString(wsgi_base_dict, "SERVER_NAME", PyUnicode_FromFormat(""));
357 PyDict_SetItemString(wsgi_base_dict, "SERVER_PORT", PyUnicode_FromFormat(""));
358 }
359 }
360 }
356 PyDict_SetItemString(wsgi_base_dict, "SERVER_NAME", PyString_FromFormat(""));
357 PyDict_SetItemString(wsgi_base_dict, "SERVER_PORT", PyString_FromFormat(""));
358 }
359 }
360 }
+0
-19
tests/signal.py less more
0 import signal
1
2 n = 0
3
4 def app(e, s):
5 s('200 ok', [])
6 return b'%d times' % n
7
8
9 def inc_counter(*args):
10 global n
11 n += 1
12 print('Increased counter to',n)
13
14
15 signal.signal(signal.SIGTERM, inc_counter)
16
17 import bjoern
18 bjoern.run(app, '0.0.0.0', 8080)
0 import signal
1
2 n = 0
3
4 def app(e, s):
5 s('200 ok', [])
6 return b'%d times' % n
7
8
9 def inc_counter(*args):
10 global n
11 n += 1
12 print('Increased counter to',n)
13
14
15 signal.signal(signal.SIGTERM, inc_counter)
16
17 import bjoern
18 bjoern.run(app, '0.0.0.0', 8080)