Created
June 28, 2018 20:08
-
-
Save aniketp/95f2c3544b697d422ac23a064523d6c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Process, Manager | |
from fasttext import FastVector | |
# Returns a sample fastVector object | |
def createFastVector(): | |
# Create for English vector-wiki | |
en_dict = FastVector(vector_file='wiki.en.vec') | |
return en_dict | |
def serverFunc(vector): | |
print(vector) | |
# Result: Namespace(en_vector=<__main__.FastVector object at 0x7fb018fbadd8>) | |
if __name__ == '__main__': | |
manager = Manager() | |
fastVector = createFastVector() | |
# Using Managers.Namespace to store fastVector object | |
vector = manager.Namespace() | |
vector.en_vector = fastVector | |
# Multiple such processes can be used to send a READ request | |
# to target function, i.e the server hosting FastVector object | |
process = Process(target=serverFunc, args=(vector)) | |
process.start() | |
process.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment