小编Pyj*_*ava的帖子

如何在Python中使用异步io(快速方式)将数据从一个s3存储桶复制到另一个存储桶?

我想以异步方式将多个对象从一个 s3 存储桶复制到另一个存储桶,并且我想保持其状态。

我已经尝试在 s3 boto3 库上使用 async 和 wait ,但它们执行顺序复制。我也尝试过使用 aiobotocore 和 aioboto3 库,但它们没有 boto3 中使用的正确的 copy_object API。

async def copy_file(taskdescriptor: list, buckets: list):
    #loop = asyncio.get_event_loop()
    print("taskdescriptor", taskdescriptor)
    for job in taskdescriptor[0]:
        print("Inside copy", job , buckets)

        src_bucket = buckets[0]
        dest_bucket = buckets[1]
        src_path = job[0] 
        dest_path = job[1]
        src_loc = {"Bucket": src_bucket, "Key": src_path}
        #loop = asyncio.get_event_loop()
        #session = aiobotocore.get_session()
        async with aioboto3.client('s3') as asyncs3:
            print("s3 copy from {} to {}".format(src_path, dest_path))
            resp = await asyncs3.copy_object(Bucket=dest_bucket, Key=dest_path, …
Run Code Online (Sandbox Code Playgroud)

python-3.x python-asyncio aiohttp boto3 aws-lambda

7
推荐指数
0
解决办法
998
查看次数

如何使用perl获取值的索引或变量长度(类似于java的动态列表长度)?

我有2个输出: -

7: ib1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP>    
9: bondib0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP>
Run Code Online (Sandbox Code Playgroud)

使用perl我想获得substr ib1和bondib0.目前,如果我设置

substr($line,3,3); this will return ib1
substr($line,3,7); this will return bondib0
Run Code Online (Sandbox Code Playgroud)

我想在上面有一个substr,怎么做?

像substr($ line,3,index($ line,":"));

请告诉我如何获得3和7个以上索引的动态值,因为值的长度不同.

perl

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

从另一个调用一个Perl程序

我有两个Perl文件,我想用另一个参数调用另一个文件

第一个文件 a.pl

$OUTFILE  = "C://programs/perls/$ARGV[0]";
# this should be some out file created inside work like C://programs/perls/abc.log
Run Code Online (Sandbox Code Playgroud)

第二档 abc.pl

require "a.pl" "abc.log";

# $OUTFILE is a variable inside a.pl and want to append current file's name as log.
Run Code Online (Sandbox Code Playgroud)

我希望它创建一个名为log的输出文件,作为当前文件的名称.

一个约束了我就是用$OUTFILE在这两个a.plabc.pl.

如果有更好的方法,请建议.

perl

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

用于从ip命令获取inet的Perl脚本

我试图使用ip命令获取inet它在cmd提示符下工作正常但是如果我在perl脚本中添加它,它没有按预期执行.脚本如下: -

ip.pl

use strict;
my $a = `ip -f inet addr show eth0| grep -Po 'inet \K[\d.]+'`;
chomp($a);
print $a;
Run Code Online (Sandbox Code Playgroud)

使用"perl a.pl"执行上面只返回"ip -f inet addr show eth0 | grep -Po'inet\K [\ d.] +'"返回inet值.如何使用perl脚本执行它?

perl

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

标签 统计

perl ×3

aiohttp ×1

aws-lambda ×1

boto3 ×1

python-3.x ×1

python-asyncio ×1