Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Send IPC message from main process to a reader in the task pool #22

Open
GnuRant opened this issue Apr 26, 2017 · 5 comments
Open

Send IPC message from main process to a reader in the task pool #22

GnuRant opened this issue Apr 26, 2017 · 5 comments

Comments

@GnuRant
Copy link

GnuRant commented Apr 26, 2017

Hello,
I'm trying to send a message from the main process to all the render processes in the task pool.
Now I'm sending the message using the standard electron ipcMain.send() but unfortunately the message is not received by the background render processes.

Any idea on how to make it work?

@anaisbetts
Copy link
Contributor

Can you talk more about what you're trying to do? This is probably a pretty race-condition'y thing to do

@GnuRant
Copy link
Author

GnuRant commented Apr 27, 2017

Hi @paulcbetts,
I'm building a file uploader to upload files to S3. I'm using electron-remote to spawn a worker for each file in the upload queue.

FileUploader = ElectronRemote.requireTaskPool('./electron/workers/uploadWorker', 4, 24*60*60*1000);

the code above is for the upload

// send to the upload workers a file to upload
    private async doUpload(file: ContentFile) {
        // it doesn't return until FileUploader uploaded the data,
        // the queue is blocked by the evaporate uploading process that is synchronous, wait until an
        // upload is success or error
        await FileUploader.doUpload(file);
    }

My idea is to send a message from the main thread (upload manager) to all the workers in the task pool in order to pause/resume the uploads.

Maybe I'm approaching the problem in the wrong way. How can I implement a bidirectional communication between the workers and the upload manager?

@anaisbetts
Copy link
Contributor

anaisbetts commented Apr 27, 2017

Maybe I'm approaching the problem in the wrong way. How can I implement a bidirectional communication between the workers and the upload manager?

I don't think you're approaching it wrong, I just think we don't have a super great solution for this right now. How would you picture that API to work? (I have some ideas but I'm not sure if other people would grok them)

@GnuRant
Copy link
Author

GnuRant commented May 2, 2017

I don't think you're approaching it wrong, I just think we don't have a super great solution for this right now. How would you picture that API to work? (I have some ideas but I'm not sure if other people would grok them)

The ideal for me would be to have an API similar to the one exposed by the default ipc module of electron, which ideally allows to subscribe to one or more events (ipcRenderer.on(channel, listener)). Do you think this kind of approach would also work for async function calls?

Did you have something else in mind?

@GnuRant
Copy link
Author

GnuRant commented May 17, 2017

@paulcbetts Any idea ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants