Scala script wait for mongo to complete task
问题 I'm writing a simple scala-based script which supposed to insert some data into Mongo collection. The problem is, that script exits before mongo finishes it's task. What is the idiomatic/best approach to deal with the problem, considering following script: #!/usr/bin/env scalas /*** scalaVersion := "2.12.2" libraryDependencies ++= { Seq( "org.mongodb.scala" %% "mongo-scala-driver" % "2.1.0" ) } */ import org.mongodb.scala._ val mongoClient: MongoClient = MongoClient("mongodb://localhost") val