{"action":"created","issue":{"url":"https://api.github.com/repos/materialsproject/maggma/issues/29","repository_url":"https://api.github.com/repos/materialsproject/maggma","labels_url":"https://api.github.com/repos/materialsproject/maggma/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/materialsproject/maggma/issues/29/comments","events_url":"https://api.github.com/repos/materialsproject/maggma/issues/29/events","html_url":"https://github.com/materialsproject/maggma/issues/29","id":332325810,"node_id":"MDU6SXNzdWUzMzIzMjU4MTA=","number":29,"title":"Possible solution to \"stalled\" Runner.run ?","user":{"login":"dwinston","id":1497854,"node_id":"MDQ6VXNlcjE0OTc4NTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1497854?v=4","gravatar_id":"","url":"https://api.github.com/users/dwinston","html_url":"https://github.com/dwinston","followers_url":"https://api.github.com/users/dwinston/followers","following_url":"https://api.github.com/users/dwinston/following{/other_user}","gists_url":"https://api.github.com/users/dwinston/gists{/gist_id}","starred_url":"https://api.github.com/users/dwinston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwinston/subscriptions","organizations_url":"https://api.github.com/users/dwinston/orgs","repos_url":"https://api.github.com/users/dwinston/repos","events_url":"https://api.github.com/users/dwinston/events{/privacy}","received_events_url":"https://api.github.com/users/dwinston/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-14T09:38:56Z","updated_at":"2018-06-14T19:21:33Z","closed_at":null,"author_association":"MEMBER","body":"I don't know if this is still an issue / was solved, but I recall folks like @montoyjh mentioning that builder runs mysteriously stalled for a long time without seemingly doing any `process_item`/`update_targets` work. I came across the following in an email list to which I subscribe, and I thought it might be applicable to our `MultiprocProcessor`:\r\n\r\n> So, how is `multiprocessing.Pool` broken? The way it works is to start subprocesses by using the POSIX (aka Unix) fork() syscall, which clones all the memory in the process. Typically you then call some variant of execv(), which replaces the copy with a completely new process, but not multiprocessing.Pool. So, when you start a subprocess like this it’s a copy of everything in the parent Python process.\r\n>\r\n> For example, any state stored in a Python module will be copied. I’ve seen child processes in the pool get really confused and try to rotate the parent process' logs, because the Python standard library logging module stores some state about log handling and that gets copied wholesale.\r\n>\r\n> Also, any threads in the parent process are now missing in the forked copy. If your library starts some threads in the background your library will be broken in the subprocess (it’s obscure, but I maintain a library that actually does this). More commonly, [thread locks might end up in a bad state](https://rachelbythebay.com/w/2011/06/07/forked/), which is my guess for what happened in my case.\r\n>\r\n> In short, the end result is a pool of processes that work some of the time—but sometimes break mysteriously. Python does support a process pool that doesn’t do this horrible fork()-only trick, but you need to know it’s there, and you need to know that the default is broken.\r\n\r\nThe key idea is to [override the context's default \"fork\" start method](https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods). It's the default, but the docs state that \"safely forking a multithreaded process is problematic.\" I know `MultiprocProcessor` starts a separate thread for updating targets, and uses locks for synchronization, so there may be something screwy happening that can be avoided e.g. by setting the start method to be \"forkserver\" if supported on the host OS, and \"spawn\" otherwise."},"comment":{"url":"https://api.github.com/repos/materialsproject/maggma/issues/comments/397409473","html_url":"https://github.com/materialsproject/maggma/issues/29#issuecomment-397409473","issue_url":"https://api.github.com/repos/materialsproject/maggma/issues/29","id":397409473,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzQwOTQ3Mw==","user":{"login":"montoyjh","id":6494516,"node_id":"MDQ6VXNlcjY0OTQ1MTY=","avatar_url":"https://avatars1.githubusercontent.com/u/6494516?v=4","gravatar_id":"","url":"https://api.github.com/users/montoyjh","html_url":"https://github.com/montoyjh","followers_url":"https://api.github.com/users/montoyjh/followers","following_url":"https://api.github.com/users/montoyjh/following{/other_user}","gists_url":"https://api.github.com/users/montoyjh/gists{/gist_id}","starred_url":"https://api.github.com/users/montoyjh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/montoyjh/subscriptions","organizations_url":"https://api.github.com/users/montoyjh/orgs","repos_url":"https://api.github.com/users/montoyjh/repos","events_url":"https://api.github.com/users/montoyjh/events{/privacy}","received_events_url":"https://api.github.com/users/montoyjh/received_events","type":"User","site_admin":false},"created_at":"2018-06-14T19:21:33Z","updated_at":"2018-06-14T19:21:33Z","author_association":"COLLABORATOR","body":"At least part of the reason I was having issues is if there are unforeseen bugs in update_targets, the update_targets process seems to hang and limit the remaining processes somehow."}}
{"actor":{"display_login":"montoyjh"}}