我正在重写一些代码以消除全局变量并使类构造函数/析构函数句柄清理某些第三方库资源,但我担心一些代码会从类初始化列表中的另一个成员初始化一个成员.
class MyPodofoDocument {
public:
// generates pdf to stream
MyPodofoDocument(std::stringstream *pStringStream)
: device(pStringStream), document(&device)
{
}
private:
PoDoFo::PdfOutputDevice device;
PoDoFo::PdfStreamedDocument document;
PoDoFo::PdfPainter painter;
};
Run Code Online (Sandbox Code Playgroud)
使用这个类的代码不需要查看使用该库的所有细节,但是我隐藏它们的方式使它依赖于使用成员初始化其他成员,然后才能访问构造函数的实际代码块,在那里它有一个有效的this指针.
它适用于单元测试骨架,所以我的问题基本上是,"这样可以,便携且安全吗?"
我有一个可以单独工作的 dockerfile
docker build -t image_apache 。
docker run -tid -p 5000:80 --name=container_apache image_apache
这有效,我可以使用 127.0.0.1:5000 连接到其网络服务器
但是,当我尝试创建 docker-compose.yml 文件来使用 docker-compose 构建和运行映像时,它似乎根本没有公开端口。
这是 docker-compose.yaml
version: '3'
services:
deploy_test:
ports:
- "8080:80"
build: .
working_dir: /tmp/artifacts
Run Code Online (Sandbox Code Playgroud)
docker-compose构建
docker-compose运行deploy_test
我的浏览器无法连接到127.0.0.1:8080,并且容器中的apache日志没有显示任何尝试。
我的端口语法是否错误?它与在线示例相匹配。
这是一个错误吗?它演示了当您使用libtiff从打开的tiff文件句柄中提取图像时会发生什么.它在python 2.x中工作,在python 3.2.3中不起作用
import os
# any file will work here, since it's not actually loading the tiff
# assuming it's big enough for the seek
filename = "/home/kostrom/git/wiredfool-pillow/Tests/images/multipage.tiff"
def test():
fp1 = open(filename, "rb")
buf1 = fp1.read(8)
fp1.seek(28)
fp1.read(2)
for x in range(16):
fp1.read(12)
fp1.read(4)
fd = os.dup(fp1.fileno())
os.lseek(fd, 28, os.SEEK_SET)
os.close(fd)
# this magically fixes it: fp1.tell()
fp1.seek(284)
expect_284 = fp1.tell()
print ("expected 284, actual %d" % expect_284)
test()
Run Code Online (Sandbox Code Playgroud)
我觉得错误的输出是:预期284,实际-504
取消注释fp1.tell()会产生一些......副作用...这会稳定py3句柄,我不知道为什么.如果有人可以测试其他版本的python3,我也很感激.