Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue on closing closed channel #18

Open
norbertogomez opened this issue Mar 30, 2021 · 1 comment
Open

Issue on closing closed channel #18

norbertogomez opened this issue Mar 30, 2021 · 1 comment

Comments

@norbertogomez
Copy link

norbertogomez commented Mar 30, 2021

Using your solution as part of a repository in a web server, the first API call does the import in a successful way. On the second call, looks like the library is trying to close an already closed channel.

The error I am getting:

panic: close of closed channel
marketing-feed-manager | 
marketing-feed-manager | goroutine 585 [running]:
marketing-feed-manager | github.com/gosuri/uiprogress.(*Progress).Listen(0xc000041680)
marketing-feed-manager | 	/go/pkg/mod/github.com/gosuri/[email protected]/progress.go:117 +0x108
marketing-feed-manager | created by github.com/gosuri/uiprogress.(*Progress).Start
marketing-feed-manager | 	/go/pkg/mod/github.com/gosuri/[email protected]/progress.go:134 +0x3f

The way I use the mongoimport library:

	conn := mongoimport.MongoConnection{
		AuthDatabaseName: m.AuthDatabase,
		DatabaseName:     m.Database,
		Host:             m.Host,
		Password:         m.Password,
		Port:             m.Port,
		User:             m.User,
	}

	datasources := []*mongoimport.Datasource{
		{
			Description:  "All offers",
			FileProvider: &files.List{Files: []string{filepath}},
			Options: mongoimport.Options{
				Collection: m.Collection + market.Code,
			},
		},
	}

	csvLoader := loaders.DefaultCSVLoader()
	csvLoader.Excel = false
	importer := mongoimport.Import{
		Sources:    datasources,
		Connection: &conn,
		Options: mongoimport.Options{
			EmptyCollection:    opt.SetFlag(true),
			IndividualProgress: opt.SetFlag(false),
			Loader:             loaders.Loader{SpecificLoader: csvLoader},
			FailOnErrors:       opt.SetFlag(false),
			PostLoad: func(loaded map[string]interface{}) ([]interface{}, error) {
				return []interface{}{loaded}, nil
			},
		},
	}

	result, err := importer.Start()

After a debugging session, I think the issue could be in here

@jaumebecks
Copy link

jaumebecks commented Mar 31, 2021

I think this is related to gosuri/uiprogress#40 @romnn
Specifically when initializing a UI progress bar in

uiprogress.Start()
, you might use uip := uiprogress.New() instead

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

No branches or pull requests

2 participants