grumpyhome / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
420 stars 18 forks source link

Support creating, getting and putting to native Go channels #23

Open alanjds opened 6 years ago

alanjds commented 6 years ago

google/grumpy#96 opened by @mattseh on 12 Jan 2017

Hi,

Very cool project.

I grepped the code, but couldn't find a mention of channels or goroutines.

Are they available, either directly or via the python stdlib?

Thanks

alanjds commented 6 years ago

Comment by trotterdylan Thursday Jan 12, 2017 at 16:27 GMT


Thanks for the interest in the project! The normal Python threading libraries are based on goroutines. So for example, this will implicitly start a goroutine:

import threading
def target():
  print 'from a goroutine!'
t = threading.Thread(target=target)
t.start()
t.join()
alanjds commented 6 years ago

Comment by trotterdylan Thursday Jan 12, 2017 at 16:28 GMT


Channels will be exposed implicitly as Queue objects. They will also be directly usable as native Go objects, but that work has not yet been done. Reopening this to capture that work.

alanjds commented 6 years ago

Comment by toadzhou Friday Jan 13, 2017 at 05:20 GMT


very good project! Sustained attention # go build -o hello hello.go /root/grumpy/build/src/grumpy/file.go:18:2: non-standard import "bufio" in standard package "grumpy" /root/grumpy/build/src/grumpy/lib/threading/module.go:4:2: non-standard import "reflect" in standard package "grumpy/lib/threading" import cycle not allowed package main imports grumpy imports bufio imports bytes imports errors imports runtime imports runtime/internal/atomic imports unsafe imports runtime

alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 05:24 GMT


@toadzhou I think that's a different issue. Can you file a different issue? It would be useful to see the output of go version.

alanjds commented 6 years ago

Comment by meadori Thursday Jan 19, 2017 at 01:52 GMT


I would like to take a stab at implementing Queues in terms of channels if no one is working on it yet.

alanjds commented 6 years ago

Comment by trotterdylan Thursday Jan 19, 2017 at 02:12 GMT


It's not being worked on to my knowledge. On Wed, Jan 18, 2017 at 5:52 PM Meador Inge notifications@github.com wrote:

I would like to take a stab at implementing Queues in terms of channels if no one is working on it yet.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/google/grumpy/issues/96#issuecomment-273659296, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHLexFQaT4Ntrn74n2g_SSz3UdZG6llks5rTsHOgaJpZM4LhiXN .

alanjds commented 6 years ago

Comment by choleraehyq Thursday Jan 19, 2017 at 07:49 GMT


I don't think implementing Queue based on channal is a good idea. Even in Go, we often reimplement a queue without channals rather than using channals.

How do you think about refactoring threading.Event using channal?