GithubHelp home page GithubHelp logo

deadlock about fsnotify HOT 16 CLOSED

howeyc avatar howeyc commented on August 16, 2024
deadlock

from fsnotify.

Comments (16)

howeyc avatar howeyc commented on August 16, 2024

Interesting, may have something to do with Closing and then opening another watch.
What OS are you using? Or does it happen on multiple?

from fsnotify.

skelterjohn avatar skelterjohn commented on August 16, 2024

This happened on linux. I also have a mac I can test this on - I'll get back to you.

from fsnotify.

skelterjohn avatar skelterjohn commented on August 16, 2024

It's not an issue on os x.

from fsnotify.

howeyc avatar howeyc commented on August 16, 2024

Sorry I don't have time to test right now, but if you have time, could you try and drain the Event and Error channels after close (do a for range on them)?

If not, I'll try something later.

If my intuition is right and that stops the deadlock I can work on a proper fix.

from fsnotify.

skelterjohn avatar skelterjohn commented on August 16, 2024

I am unable to reproduce the problem on this linux machine (yay?) When I get home I'll test again on the machine where I saw the problem, and let you know. Maybe I'm an idiot - it happens.

from fsnotify.

skelterjohn avatar skelterjohn commented on August 16, 2024

On my home machine this appears not to help.

from fsnotify.

howeyc avatar howeyc commented on August 16, 2024

Okay, I'm having trouble finding the issue, let's review:

Are you monitoring both the Event and Error channels?

ex:

go func() {
    for event := range w.Event {
        log.Print(event)
    }
}()
go func() {
    for err := range w.Error {
        log.Print(err)
    }
}()
/* ... do stuff ... */
w.Close()

Also, just in case, please try latest change I made.

If this doesn't help, would you perhaps be willing to give more context (ie, more lines of code) so I can better trouble shoot the issue.

from fsnotify.

skelterjohn avatar skelterjohn commented on August 16, 2024

Draining the events and errors in a separate goroutine seems to have fixed
the issue.

On Tue, May 22, 2012 at 10:30 AM, Chris Howey <
[email protected]

wrote:

Okay, I'm having trouble finding the issue, let's review:

Are you monitoring both the Event and Error channels?

ex:

go func() {
   for event := range w.Event {
       log.Print(event)
   }
}()
go func() {
   for err := range w.Error {
       log.Print(err)
   }
}()
/* ... do stuff ... */
w.Close()

Also, just in case, please try latest change I made.

If this doesn't help, would you perhaps be willing to give more context
(ie, more lines of code) so I can better trouble shoot the issue.


Reply to this email directly or view it on GitHub:
#5 (comment)

from fsnotify.

howeyc avatar howeyc commented on August 16, 2024

Great!

I'll update the README to make it clear that you must watch Error and Event channels in separate go routine.

Thanks.

from fsnotify.

skelterjohn avatar skelterjohn commented on August 16, 2024

I don't know if that's the best solution - it should be possible to make it
so there is no deadlock there in any context.

On Tue, May 22, 2012 at 10:56 AM, Chris Howey <
[email protected]

wrote:

Great!

I'll update the README to make it clear that you must watch Error and
Event channels in separate go routine.

Thanks.


Reply to this email directly or view it on GitHub:
#5 (comment)

from fsnotify.

howeyc avatar howeyc commented on August 16, 2024

I'll take a look, but once channels are involved it's kind of difficult to do so.

Once I attempt to write to a channel, and you are not reading from it, well... you know what happens.

from fsnotify.

skelterjohn avatar skelterjohn commented on August 16, 2024

Instead of:
for {
ch <- something
}

You'd do:
loop:
for {
select {
case ch <- something:
case <-stopSending:
break loop
}
}

and when .Close() was called, you'd send a value on stopSending.

from fsnotify.

daaku avatar daaku commented on August 16, 2024

fwiw, I also tripped up on this. It would be nice if it wasn't required to read from the channel in a separate goroutine.

from fsnotify.

howeyc avatar howeyc commented on August 16, 2024

Yeah... I understand.

Hopefully it wont take me too long to find the time and make the required changes.

Thanks for the input.

from fsnotify.

skelterjohn avatar skelterjohn commented on August 16, 2024

Thanks for the nice cross-platform notify lib! Very useful.

from fsnotify.

daaku avatar daaku commented on August 16, 2024

+1 -- thanks for writing this and making it available!

from fsnotify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.