Alex Martelli <aleaxit at yahoo.com> writes: > On Tuesday 21 October 2003 06:26 pm, Thomas Heller wrote: > ... >> Yet another approach would be to use the delay_load feature of MSVC, it >> allows dynamic loading of the dlls at runtime, ideally without changing >> the source code. >> >> So far I have never tried that, does anyone know if this really works? > > Yes, back when I was in think3 we experimented extensively as soon as > it was available (still in a beta of -- I don't recall if it was the SDK or > VStudio 6), and except for a few specific libraries that gave some trouble > (MSVCRT.DLL and the MFC one, only -- I think because they did > something to the memory allocation mechanisms, MSVCRT having it > and MFC changing it -- perhaps it was because we were ALSO using > other memory-related tools in DLL's, e.g. leak-detectors), it always worked > smoothly and "spread" the load, making the app startup faster. So we > set the two DLL's that gave us trouble for load and startup and the rest > for delayed load and lived happily ever after (I don't even recall exactly > HOW we did that, it WAS years ago...). After installing MSVC6 on a win98 machine, where I could rename wsock32.dll away (which was not possible on XP due to file system protection), I was able to change socketmodule.c to use delay loading of the winsock dll. I had to wrap up the WSAStartup() call inside a __try {} __except {} block to catch the exception thrown. With this change, _socket (and maybe also select) could then also be converted into builtin modules. Guido, what do you think? Thomas PS: Here's the exception raised when loading of wsock32.dll fails: >>> import _socket Traceback (most recent call last): File "<stdin>", line1m in ? ImportError: WSAStartup failed: error code -1066598274 and here's the tiny patch: Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.271.6.5 diff -c -r1.271.6.5 socketmodule.c *** socketmodule.c 20 Oct 2003 14:34:47 -0000 1.271.6.5 --- socketmodule.c 21 Oct 2003 18:21:39 -0000 *************** *** 3381,3387 **** WSADATA WSAData; int ret; char buf[100]; ! ret = WSAStartup(0x0101, &WSAData); switch (ret) { case 0: /* No error */ Py_AtExit(os_cleanup); --- 3381,3391 ---- WSADATA WSAData; int ret; char buf[100]; ! __try { ! ret = WSAStartup(0x0101, &WSAData); ! } __except (ret = GetExceptionCode(), EXCEPTION_EXECUTE_HANDLER) { ! ; ! } switch (ret) { case 0: /* No error */ Py_AtExit(os_cleanup);
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4