Posts

Showing posts from November 13, 2018

Exactly when does the background script in a chrome extension get run?

Image
up vote 0 down vote favorite In my chrome extension, I have a background script that will fetch some data that it will need using a XMLHttpRequest . // note that this code is in the global scope i.e. outside of any function // also note that I got this code from the page talking about XMLHttpRequest var myData = var xhr = new XMLHttpRequest() xhr.onreadystatechange = handleStateChange xhr.open("GET", "...", true) xhr.send() function handleStateChange() myData = Object.values(JSON.parse(xhr.responseText)) I want to know when will xor.send() be run. I observed that every time I reload the extension by pressing on the button, xhr.send() will be called. I also observed that opening a new tab/window doesn't cause the background script to be run again. I also found this page, that the background page gets "loaded" and "unloaded", but it says very little about when the code in the global scope of the background script is run. Does ...

How does client data go to sub thread of the server rather than original listening thread?

Image
up vote 0 down vote favorite My question is about client server communication in the following scenario. A server listens on port 21 and is capable of serving multiple incoming connections simultaneously from clients (C1, C2 and so on ) without blocking them So when a client C1 connects to server S on the port 21 the server accepts the connection on main thread and creates a new thread TH1 and let it handle the client request while the main thread starts listing to port 21 again to accept new clients. TH1 sends some data back to client C1, C1 reveives the data and send more data to the server on the same connection which was establisehd on port 21. This data arrives at server and is received by thread Th1 while the main the main thread of Server continues to listen on port 21. My question is how does the further data sent by client C1 on the same connection which was made on port 21 automatically goes to the thread Th1 ? even though the main thread of server is listening on...

Compiling multiple files to exe

Image
up vote 1 down vote favorite I got multiple files to compile to a standalone exe using cython. compile.py from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext ext_modules = [ Extension("TheMainFile", ["TheMainFile.py"]), Extension("HelperClass", ["HelperClass.py"]), Extension("HelperClass2", ["HelperClass2.py"]), ] setup( name = 'Main', cmdclass = 'build_ext': build_ext, ext_modules = ext_modules ) The main file that should be run by the exe is TheMainFile running the following command python .compiler.py build_ext --inplace creates 3 .c files, in the build dir however is no .exe, just .lib , .exp and .obj files. Manually adding these files to a VS Projects to build, results in the following error "Python.h": No such file or directory Adding the following files to the project from C:Pythoninclude lastly results in ...