小编ind*_*ngh的帖子

类字段/实例变量的Pycharm类型提示

每当我们需要Java中的新对象时,我们声明类型和名称选择给它一个初始值.在Python中我们不能这样做,因为我们不声明类型.

如何解决这个问题,因为如果没有声明类型; 我没有得到任何代码完成提示.就像特定对象的字段或我们可以调用对象的任何方法一样......

 class Album:
    def __init__(self, name, Photo, next):
        self.name = name
        self.Photo = None
        self.next = next

    def __str__(self):
        return "Album name is: " + self.name


class Photo:
    def __init__(self, name, caption, Tag, next):
        self.name = name
        self.caption = caption
        self.Tag = Tag
        self.next = next

    def __str__(self):
        return "Photo name is: " + self.name + " with caption: " + self.caption


class Tag:
    def __init__(self, type, info, next):
        self.name = type
        self.info = info
        self.next = next …
Run Code Online (Sandbox Code Playgroud)

python type-hinting pycharm

6
推荐指数
1
解决办法
2704
查看次数

Akka Ask模式的Timeout阻止代码执行

我刚开始学习Scala的Akka库.我遇到了使用Ask模式从Actor获取响应(就像启动一个线程来完成一些计算并获得结果).

下面是我的代码,其中我使用了Ask模式,其中Timeout阻止它执行.为什么?

import akka.actor._
import akka.routing._
import akka.util.Timeout
import akka.pattern.ask
import java.math.BigInteger
import java.time.LocalDate
import scala.concurrent.duration._
import scala.concurrent.Await
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global 
import scala.util.{Success, Failure}


object Main extends App {

  val system = ActorSystem("listRetriever")
  val workerActor = system.actorOf(Props[Worker], "workerActor")
  val listRetriever= new listRetriever
  implicit val timeout = Timeout(10 seconds)

  val future = workerActor ? new Work(date, listRetriever)

  future onComplete {
    case Success(result: Result) => println(result.getList())
    case Failure(result) => println(result)
  }

  system.shutdown
}
Run Code Online (Sandbox Code Playgroud)

parallel-processing scala akka

1
推荐指数
1
解决办法
3794
查看次数